|
@@ -351,9 +351,24 @@ func (s *webForwardingService) AddWebForwarding(ctx context.Context, req *v1.Web
|
|
|
if v.IsHttps == isHttps {
|
|
|
apiType = protocolHttps
|
|
|
}
|
|
|
+ host, port, err := net.SplitHostPort(v.Addr)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ var addrPunyPort string
|
|
|
+ addrPunyPort = v.Addr
|
|
|
+ // 如果是 IP 地址,不需要转换
|
|
|
+ if ok := net.ParseIP(host); ok == nil {
|
|
|
+ _, hostPuny, err := s.wafformatter.ConvertToPunycodeIfIDN(ctx, host)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ addrPunyPort = fmt.Sprintf("%s:%s", hostPuny, port)
|
|
|
+ }
|
|
|
+
|
|
|
id, err := s.wafformatter.AddOrigin(ctx, v1.WebJson{
|
|
|
ApiType: apiType,
|
|
|
- BackendList: v.Addr,
|
|
|
+ BackendList: addrPunyPort,
|
|
|
Host: v.CustomHost,
|
|
|
Comment: req.WebForwardingData.Comment,
|
|
|
})
|