Add support for http proxy

This commit is contained in:
Wayback Archiver 2023-05-20 14:59:12 +01:00
parent 6fcd53d2a0
commit 0b18a00fcb
No known key found for this signature in database
GPG key ID: 57D14486138C9377
5 changed files with 239 additions and 3 deletions

View file

@ -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 {