repaired the wrong IP when using in localhost (Mac os x)
it returns “[“ when using beego in local host(Mac os x 10.9) , it appears that Request.remoAddr returns “[::1]:****”
Showing
1 changed file
with
2 additions
and
0 deletions
| ... | @@ -98,8 +98,10 @@ func (input *BeegoInput) IP() string { | ... | @@ -98,8 +98,10 @@ func (input *BeegoInput) IP() string { |
| 98 | } | 98 | } |
| 99 | ip := strings.Split(input.Request.RemoteAddr, ":") | 99 | ip := strings.Split(input.Request.RemoteAddr, ":") |
| 100 | if len(ip) > 0 { | 100 | if len(ip) > 0 { |
| 101 | if ip[0] != "["{ | ||
| 101 | return ip[0] | 102 | return ip[0] |
| 102 | } | 103 | } |
| 104 | } | ||
| 103 | return "127.0.0.1" | 105 | return "127.0.0.1" |
| 104 | } | 106 | } |
| 105 | 107 | ... | ... |
-
Please register or sign in to post a comment