diff --git a/README.MD b/README.MD index 7eee0b379..38c7aeb28 100644 --- a/README.MD +++ b/README.MD @@ -64,7 +64,7 @@ The `Web` component performance of `GoFrame`, please refer to third-party projec - [ZTE](https://www.zte.com.cn/china/) - [Ant Financial Services](https://www.antfin.com/) - [VIVO](https://www.vivo.com/) -- [MedLinker](https://www.vivo.com/) +- [MedLinker](https://www.medlinker.com/) - [KuCoin](https://www.kucoin.io/) - [LeYouJia](https://www.leyoujia.com/) - [IGG](https://igg.com) diff --git a/net/ghttp/ghttp_request.go b/net/ghttp/ghttp_request.go index cb4a9d085..be1399734 100644 --- a/net/ghttp/ghttp_request.go +++ b/net/ghttp/ghttp_request.go @@ -216,7 +216,7 @@ func (r *Request) GetClientIp() string { func (r *Request) GetRemoteIp() string { array, _ := gregex.MatchString(`(.+):(\d+)`, r.RemoteAddr) if len(array) > 1 { - return array[1] + return strings.Trim(array[1], "[]") } return r.RemoteAddr } diff --git a/net/ghttp/ghttp_z_unit_feature_ip_test.go b/net/ghttp/ghttp_z_unit_feature_ip_test.go index 4873a32ad..12ec11375 100644 --- a/net/ghttp/ghttp_z_unit_feature_ip_test.go +++ b/net/ghttp/ghttp_z_unit_feature_ip_test.go @@ -32,10 +32,14 @@ func TestRequest_GetRemoteIp(t *testing.T) { time.Sleep(100 * time.Millisecond) - client := g.Client() - client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p)) + clientV4 := g.Client() + clientV4.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p)) - t.Assert(client.GetContent(ctx, "/"), "127.0.0.1") + clientV6 := g.Client() + clientV6.SetPrefix(fmt.Sprintf("http://[::1]:%d", p)) + + t.Assert(clientV4.GetContent(ctx, "/"), "127.0.0.1") + t.Assert(clientV6.GetContent(ctx, "/"), "::1") }) } diff --git a/text/gstr/gstr_domain.go b/text/gstr/gstr_domain.go index ae4155277..45f31bb72 100644 --- a/text/gstr/gstr_domain.go +++ b/text/gstr/gstr_domain.go @@ -24,7 +24,7 @@ func IsSubDomain(subDomain string, mainDomain string) bool { // Eg: // "s.s.goframe.org" is not sub-domain of "*.goframe.org" // but - // "s.s.goframe.org" is not sub-domain of "goframe.org" + // "s.s.goframe.org" is sub-domain of "goframe.org" if mainLength > 2 && subLength > mainLength { return false }