mirror of https://github.com/schollz/croc.git
add geoip for displaying the place names
This commit is contained in:
parent
386f4ff958
commit
4350d2cbed
|
@ -10,6 +10,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -618,13 +619,29 @@ func (c *Client) processMessageFileInfo(m message.Message) (done bool, err error
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(os.Stderr, "\rReceiving %s (%s) \n", fname, utils.ByteCountDecimal(totalSize))
|
fmt.Fprintf(os.Stderr, "\rReceiving %s (%s) \n", fname, utils.ByteCountDecimal(totalSize))
|
||||||
}
|
}
|
||||||
fmt.Fprintf(os.Stderr, "\nReceiving (<-%s)\n", c.ExternalIPConnected)
|
place := getPlace(c.ExternalIPConnected)
|
||||||
|
if place != "" {
|
||||||
|
fmt.Fprintf(os.Stderr, "\nReceiving (<-%s/%s)\n", place, c.ExternalIPConnected)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(os.Stderr, "\nReceiving (<-%s)\n", c.ExternalIPConnected)
|
||||||
|
}
|
||||||
|
|
||||||
log.Debug(c.FilesToTransfer)
|
log.Debug(c.FilesToTransfer)
|
||||||
c.Step2FileInfoTransfered = true
|
c.Step2FileInfoTransfered = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPlace(ip string) (place string) {
|
||||||
|
resp, err := http.Get("https://geoip.schollz.com/" + strings.Split(ip, ":")[0])
|
||||||
|
if err != nil {
|
||||||
|
// handle err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
placeB, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
place = string(placeB)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) procesMesssagePake(m message.Message) (err error) {
|
func (c *Client) procesMesssagePake(m message.Message) (err error) {
|
||||||
log.Debug("received pake payload")
|
log.Debug("received pake payload")
|
||||||
// if // c.spinner.Suffix != " performing PAKE..." {
|
// if // c.spinner.Suffix != " performing PAKE..." {
|
||||||
|
|
Loading…
Reference in New Issue