-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathproxy_test.go
More file actions
34 lines (30 loc) · 782 Bytes
/
proxy_test.go
File metadata and controls
34 lines (30 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package websocketproxy
import (
"crypto/tls"
"net/http"
"testing"
)
func TestNewWebsocketProxy(t *testing.T) {
tlsc := tls.Config{InsecureSkipVerify: true}
wp, err := NewProxy("ws://www.baidu.com:80/ajaxchattest", auth, SetTLSConfig(&tlsc))
if err != nil {
t.Fatal(err)
}
http.HandleFunc("/wsproxy", wp.Proxy)
http.ListenAndServe(":9696", nil)
}
func TestNewHandler(t *testing.T) {
tlsc := tls.Config{InsecureSkipVerify: true}
wp, err := NewProxy("ws://www.baidu.com:80/ajaxchattest", auth, SetTLSConfig(&tlsc))
if err != nil {
t.Fatal(err)
}
http.ListenAndServe(":9696", wp)
}
func auth(r *http.Request) error {
// Permission to verify
r.Header.Set("Cookie", "----")
// Source of disguise
r.Header.Set("Origin", "http://82.157.123.54:9010")
return nil
}