|
|
@ -18,9 +18,7 @@ import (
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
"net/url"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
|
|
|
|
"reflect"
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
@ -161,13 +159,7 @@ func NewDirect(opts Options) (*Direct, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewHostinfo() *tailcfg.Hostinfo {
|
|
|
|
func NewHostinfo() *tailcfg.Hostinfo {
|
|
|
|
var hostname string
|
|
|
|
hostname, _ := os.Hostname()
|
|
|
|
if runtime.GOOS == "android" {
|
|
|
|
|
|
|
|
hostname = androidHostname()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if hostname == "" {
|
|
|
|
|
|
|
|
hostname, _ = os.Hostname()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return &tailcfg.Hostinfo{
|
|
|
|
return &tailcfg.Hostinfo{
|
|
|
|
IPNVersion: version.LONG,
|
|
|
|
IPNVersion: version.LONG,
|
|
|
|
Hostname: hostname,
|
|
|
|
Hostname: hostname,
|
|
|
@ -175,20 +167,6 @@ func NewHostinfo() *tailcfg.Hostinfo {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var androidHostnameOnce struct {
|
|
|
|
|
|
|
|
_ structs.Incomparable
|
|
|
|
|
|
|
|
sync.Once
|
|
|
|
|
|
|
|
v string
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func androidHostname() string {
|
|
|
|
|
|
|
|
androidHostnameOnce.Do(func() {
|
|
|
|
|
|
|
|
out, _ := exec.Command("getprop", "net.hostname").Output()
|
|
|
|
|
|
|
|
androidHostnameOnce.v = strings.TrimSpace(string(out))
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return androidHostnameOnce.v
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SetHostinfo clones the provided Hostinfo and remembers it for the
|
|
|
|
// SetHostinfo clones the provided Hostinfo and remembers it for the
|
|
|
|
// next update. It reports whether the Hostinfo has changed.
|
|
|
|
// next update. It reports whether the Hostinfo has changed.
|
|
|
|
func (c *Direct) SetHostinfo(hi *tailcfg.Hostinfo) bool {
|
|
|
|
func (c *Direct) SetHostinfo(hi *tailcfg.Hostinfo) bool {
|
|
|
|