File tree Expand file tree Collapse file tree 5 files changed +16
-0
lines changed
Expand file tree Collapse file tree 5 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ appservice:
7171
7272# Bridge config
7373bridge :
74+ # Proxy for homeserver connection.
75+ hs_proxy :
7476 # Localpart template of MXIDs for WeChat users.
7577 username_template : _wechat_{{.}}
7678 # Displayname template for WeChat users.
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ const (
1818)
1919
2020type BridgeConfig struct {
21+ HomeserverProxy string `yaml:"hs_proxy"`
22+
2123 UsernameTemplate string `yaml:"username_template"`
2224 DisplaynameTemplate string `yaml:"displayname_template"`
2325 ListenAddress string `yaml:"listen_address"`
Original file line number Diff line number Diff line change 99func DoUpgrade (helper * up.Helper ) {
1010 bridgeconfig .Upgrader .DoUpgrade (helper )
1111
12+ helper .Copy (up .Str , "bridge" , "hs_proxy" )
1213 helper .Copy (up .Str , "bridge" , "username_template" )
1314 helper .Copy (up .Str , "bridge" , "displayname_template" )
1415 helper .Copy (up .Str , "bridge" , "listen_address" )
Original file line number Diff line number Diff line change @@ -265,6 +265,7 @@ func (ws *WechatService) getConn(client *WechatClient) *Conn {
265265 if conn , ok := ws .conns [client .getConnKey ()]; ok {
266266 return conn
267267 } else {
268+ // a better connection pick?
268269 for k , v := range ws .conns {
269270 client .setConnKey (k )
270271 return v
Original file line number Diff line number Diff line change 44 "context"
55 "errors"
66 "fmt"
7+ "net/http"
8+ "net/url"
79 "os"
810 "sync"
911 "time"
@@ -101,6 +103,14 @@ func (br *WechatBridge) Init() {
101103 )
102104
103105 br .WebsocketHandler = NewWebsocketCommandHandler (br )
106+
107+ if br .Config .Bridge .HomeserverProxy != "" {
108+ if proxyUrl , err := url .Parse (br .Config .Bridge .HomeserverProxy ); err != nil {
109+ br .Log .Warnfln ("Failed to parse bridge.hs_proxy: %v" , err )
110+ } else {
111+ br .AS .HTTPClient .Transport = & http.Transport {Proxy : http .ProxyURL (proxyUrl )}
112+ }
113+ }
104114}
105115
106116func (br * WechatBridge ) Start () {
You can’t perform that action at this time.
0 commit comments