File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,13 @@ func getCurrentDeviceRemoteIP() (net.IP, error) {
196196 return nil , err
197197 }
198198
199- remoteIP := net .ParseIP (string (b )).To4 ()
199+ var remoteIP net.IP
200+ ipAddr := string (b )
201+ if strings .Contains (ipAddr , ":" ) {
202+ remoteIP = net .ParseIP (ipAddr ).To16 ()
203+ } else {
204+ remoteIP = net .ParseIP (ipAddr ).To4 ()
205+ }
200206 if remoteIP == nil {
201207 return nil , fmt .Errorf ("failed to get resolve ip %q as ipv4" , b )
202208 }
Original file line number Diff line number Diff line change @@ -78,17 +78,16 @@ func AddrByHostName(hostname string) (*Record, error) {
7878 return nil , fmt .Errorf ("no addresses found for hostname %q" , hostname )
7979 }
8080
81- ipv4 := ipAddrs [0 ].To4 ()
82- if ipv4 == nil {
83- return & Record {
84- Hostname : hostname ,
85- IP : * ipAddrs [0 ],
86- }, nil
81+ var ipAddr net.IP
82+ if strings .Contains (string (* ipAddrs [0 ]), ":" ) {
83+ ipAddr = ipAddrs [0 ].To16 ()
84+ } else {
85+ ipAddr = ipAddrs [0 ].To4 ()
8786 }
8887
8988 return & Record {
9089 Hostname : hostname ,
91- IP : ipv4 ,
90+ IP : ipAddr ,
9291 }, err
9392}
9493
You can’t perform that action at this time.
0 commit comments