Add support for http proxy (#68)
* Add support for http proxy * add test case for http proxy --------- Co-authored-by: octeep <github@bandersnatch.anonaddy.com> Co-authored-by: pufferfish <74378430+pufferffish@users.noreply.github.com>
This commit is contained in:
16
routine.go
16
routine.go
@@ -137,6 +137,22 @@ func (config *Socks5Config) SpawnRoutine(vt *VirtualTun) {
|
||||
}
|
||||
}
|
||||
|
||||
// SpawnRoutine spawns a http server.
|
||||
func (config *HTTPConfig) SpawnRoutine(vt *VirtualTun) {
|
||||
http := &HTTPServer{
|
||||
config: config,
|
||||
dial: vt.Tnet.Dial,
|
||||
auth: CredentialValidator{config.Username, config.Password},
|
||||
}
|
||||
if config.Username != "" || config.Password != "" {
|
||||
http.authRequired = true
|
||||
}
|
||||
|
||||
if err := http.ListenAndServe("tcp", config.BindAddress); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Valid checks the authentication data in CredentialValidator and compare them
|
||||
// to username and password in constant time.
|
||||
func (c CredentialValidator) Valid(username, password string) bool {
|
||||
|
||||
Reference in New Issue
Block a user