()
| 28 | } |
| 29 | |
| 30 | func (pxy *HTTPSProxy) Run() (remoteAddr string, err error) { |
| 31 | xl := pxy.xl |
| 32 | routeConfig := &vhost.RouteConfig{} |
| 33 | |
| 34 | defer func() { |
| 35 | if err != nil { |
| 36 | pxy.Close() |
| 37 | } |
| 38 | }() |
| 39 | addrs := make([]string, 0) |
| 40 | for _, domain := range pxy.cfg.CustomDomains { |
| 41 | if domain == "" { |
| 42 | continue |
| 43 | } |
| 44 | |
| 45 | routeConfig.Domain = domain |
| 46 | l, errRet := pxy.rc.VhostHTTPSMuxer.Listen(pxy.ctx, routeConfig) |
| 47 | if errRet != nil { |
| 48 | err = errRet |
| 49 | return |
| 50 | } |
| 51 | xl.Info("https proxy listen for host [%s]", routeConfig.Domain) |
| 52 | pxy.listeners = append(pxy.listeners, l) |
| 53 | addrs = append(addrs, util.CanonicalAddr(routeConfig.Domain, pxy.serverCfg.VhostHTTPSPort)) |
| 54 | } |
| 55 | |
| 56 | if pxy.cfg.SubDomain != "" { |
| 57 | routeConfig.Domain = pxy.cfg.SubDomain + "." + pxy.serverCfg.SubDomainHost |
| 58 | l, errRet := pxy.rc.VhostHTTPSMuxer.Listen(pxy.ctx, routeConfig) |
| 59 | if errRet != nil { |
| 60 | err = errRet |
| 61 | return |
| 62 | } |
| 63 | xl.Info("https proxy listen for host [%s]", routeConfig.Domain) |
| 64 | pxy.listeners = append(pxy.listeners, l) |
| 65 | addrs = append(addrs, util.CanonicalAddr(routeConfig.Domain, pxy.serverCfg.VhostHTTPSPort)) |
| 66 | } |
| 67 | |
| 68 | pxy.startListenHandler(pxy, HandleUserTCPConnection) |
| 69 | remoteAddr = strings.Join(addrs, ",") |
| 70 | return |
| 71 | } |
| 72 | |
| 73 | func (pxy *HTTPSProxy) GetConf() config.ProxyConf { |
| 74 | return pxy.cfg |
nothing calls this directly
no test coverage detected