Skip to content

Commit

Permalink
Fix ws
Browse files Browse the repository at this point in the history
  • Loading branch information
ph4ntonn committed Aug 19, 2024
1 parent 6701b03 commit 507a228
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions protocol/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,6 @@ func (proto *WSProto) CNegotiate() error {
return err
}

var addrSlice []string
if proto.addr != "" {
addrSlice = strings.SplitN(proto.addr, ":", 2)
if len(addrSlice) < 2 {
return errors.New("addr is error")
}
} else {
proto.addr = "stowaway.com:22"
addrSlice = strings.SplitN(proto.addr, ":", 2)
}

var host string
if proto.domain != "" {
host = proto.domain + ":" + addrSlice[1]
} else {
host = proto.addr
}

// 发送websocket头
wsHeaders := fmt.Sprintf(`GET %s HTTP/1.1
Host: %s
Expand All @@ -63,7 +45,7 @@ Sec-WebSocket-Key: %s
Origin: http://stowaway:22
Sec-WebSocket-Version: 13
`, websocketPath, host, nonce)
`, websocketPath, proto.domain, nonce)

wsHeaders = strings.ReplaceAll(wsHeaders, "\n", "\r\n")
proto.conn.Write([]byte(wsHeaders))
Expand Down

0 comments on commit 507a228

Please sign in to comment.