diff --git a/config/config.go b/config/config.go index 3a753f7..108c135 100644 --- a/config/config.go +++ b/config/config.go @@ -12,23 +12,24 @@ import ( // Config struct type Config struct { - AddrDev string - AddrUser string - AddrHttpProxy string - DisableSignUp bool - HttpProxyRedirURL string - HttpProxyPort int - SslCert string - SslKey string - SslCacert string // mTLS for device - WebUISslCert string - WebUISslKey string - Token string - DevAuthUrl string - WhiteList map[string]bool - DB string - LocalAuth bool - SeparateSslConfig bool + AddrDev string + AddrUser string + AddrHttpProxy string + DisableSignUp bool + HttpProxyRedirURL string + HttpProxyRedirDomain string + HttpProxyPort int + SslCert string + SslKey string + SslCacert string // mTLS for device + WebUISslCert string + WebUISslKey string + Token string + DevAuthUrl string + WhiteList map[string]bool + DB string + LocalAuth bool + SeparateSslConfig bool } func getConfigOpt(yamlCfg *yaml.File, name string, opt interface{}) { @@ -50,21 +51,22 @@ func getConfigOpt(yamlCfg *yaml.File, name string, opt interface{}) { // Parse config func Parse(c *cli.Context) *Config { cfg := &Config{ - AddrDev: c.String("addr-dev"), - AddrUser: c.String("addr-user"), - AddrHttpProxy: c.String("addr-http-proxy"), - DisableSignUp: c.Bool("disable-sign-up"), - HttpProxyRedirURL: c.String("http-proxy-redir-url"), - SslCert: c.String("ssl-cert"), - SslKey: c.String("ssl-key"), - SslCacert: c.String("ssl-cacert"), - SeparateSslConfig: c.Bool("separate-ssl-config"), - WebUISslCert: c.String("webui-ssl-cert"), - WebUISslKey: c.String("webui-ssl-key"), - Token: c.String("token"), - DevAuthUrl: c.String("dev-auth-url"), - DB: c.String("db"), - LocalAuth: c.Bool("local-auth"), + AddrDev: c.String("addr-dev"), + AddrUser: c.String("addr-user"), + AddrHttpProxy: c.String("addr-http-proxy"), + DisableSignUp: c.Bool("disable-sign-up"), + HttpProxyRedirURL: c.String("http-proxy-redir-url"), + HttpProxyRedirDomain: c.String("http-proxy-redir-domain"), + SslCert: c.String("ssl-cert"), + SslKey: c.String("ssl-key"), + SslCacert: c.String("ssl-cacert"), + SeparateSslConfig: c.Bool("separate-ssl-config"), + WebUISslCert: c.String("webui-ssl-cert"), + WebUISslKey: c.String("webui-ssl-key"), + Token: c.String("token"), + DevAuthUrl: c.String("dev-auth-url"), + DB: c.String("db"), + LocalAuth: c.Bool("local-auth"), } cfg.WhiteList = make(map[string]bool) @@ -86,6 +88,7 @@ func Parse(c *cli.Context) *Config { getConfigOpt(yamlCfg, "addr-http-proxy", &cfg.AddrHttpProxy) getConfigOpt(yamlCfg, "disable-sign-up", &cfg.DisableSignUp) getConfigOpt(yamlCfg, "http-proxy-redir-url", &cfg.HttpProxyRedirURL) + getConfigOpt(yamlCfg, "http-proxy-redir-domain", &cfg.HttpProxyRedirDomain) getConfigOpt(yamlCfg, "ssl-cert", &cfg.SslCert) getConfigOpt(yamlCfg, "ssl-key", &cfg.SslKey) getConfigOpt(yamlCfg, "ssl-cacert", &cfg.SslCacert) diff --git a/http.go b/http.go index e003cc5..58f3d29 100644 --- a/http.go +++ b/http.go @@ -346,10 +346,12 @@ func httpProxyRedirect(br *broker, c *gin.Context) { httpProxySessions.Store(sid, make(chan struct{})) - c.SetCookie("rtty-http-sid", sid, 0, "", "", false, true) - c.SetCookie("rtty-http-devid", devid, 0, "", "", false, true) - c.SetCookie("rtty-http-proto", proto, 0, "", "", false, true) - c.SetCookie("rtty-http-destaddr", addr, 0, "", "", false, true) + domain := cfg.HttpProxyRedirDomain + + c.SetCookie("rtty-http-sid", sid, 0, "", domain, false, true) + c.SetCookie("rtty-http-devid", devid, 0, "", domain, false, true) + c.SetCookie("rtty-http-proto", proto, 0, "", domain, false, true) + c.SetCookie("rtty-http-destaddr", addr, 0, "", domain, false, true) c.Redirect(http.StatusFound, location) } diff --git a/main.go b/main.go index ddafd10..e648f19 100644 --- a/main.go +++ b/main.go @@ -124,6 +124,11 @@ func main() { Value: "", Usage: "url to redirect for HTTP proxy", }, + &cli.StringFlag{ + Name: "http-proxy-redir-domain", + Value: "", + Usage: "domain for HTTP proxy set cookie", + }, &cli.StringFlag{ Name: "ssl-cert", Value: "", diff --git a/rttys.conf b/rttys.conf index 177946e..dce9450 100644 --- a/rttys.conf +++ b/rttys.conf @@ -6,6 +6,9 @@ #http-proxy-redir-url: +# Used for set cookie +#http-proxy-redir-domain: + #ssl-cacert: /etc/rttys/rttys.ca #ssl-cert: /etc/rttys/rttys.crt #ssl-key: /etc/rttys/rttys.key