mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 18:17:52 -05:00
Support Listen WebSocket with TLS
This commit is contained in:
parent
fecf9cc5b8
commit
16b529093d
@ -9,6 +9,8 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||||||
ConnectionReuse bool `json:"connectionReuse"`
|
ConnectionReuse bool `json:"connectionReuse"`
|
||||||
Path string `json:"Path"`
|
Path string `json:"Path"`
|
||||||
Pto string `json:"Pto"`
|
Pto string `json:"Pto"`
|
||||||
|
Cert string `json:"Cert"`
|
||||||
|
PrivKey string `json:"PrivKet"`
|
||||||
}
|
}
|
||||||
jsonConfig := &JsonConfig{
|
jsonConfig := &JsonConfig{
|
||||||
ConnectionReuse: true,
|
ConnectionReuse: true,
|
||||||
@ -21,5 +23,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
|||||||
this.ConnectionReuse = jsonConfig.ConnectionReuse
|
this.ConnectionReuse = jsonConfig.ConnectionReuse
|
||||||
this.Path = jsonConfig.Path
|
this.Path = jsonConfig.Path
|
||||||
this.Pto = jsonConfig.Pto
|
this.Pto = jsonConfig.Pto
|
||||||
|
this.PrivKey = jsonConfig.PrivKey
|
||||||
|
this.Cert = jsonConfig.Cert
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,18 @@ func (wsl *WSListener) listenws(address v2net.Address, port v2net.Port) error {
|
|||||||
|
|
||||||
errchan := make(chan error)
|
errchan := make(chan error)
|
||||||
|
|
||||||
|
listenerfunc := func() error {
|
||||||
|
return http.ListenAndServe(address.String()+":"+strconv.Itoa(int(port.Value())), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
if effectiveConfig.Pto == "wss" {
|
||||||
|
listenerfunc = func() error {
|
||||||
|
return http.ListenAndServeTLS(address.String()+":"+strconv.Itoa(int(port.Value())), effectiveConfig.Cert, effectiveConfig.PrivKey, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
err := http.ListenAndServe(address.String()+":"+strconv.Itoa(int(port.Value())), nil)
|
err := listenerfunc()
|
||||||
errchan <- err
|
errchan <- err
|
||||||
return
|
return
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user