mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
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:
parent
d9c6eb7143
commit
25e6568f4d
7 changed files with 256 additions and 4 deletions
29
config.go
29
config.go
|
@ -45,6 +45,12 @@ type Socks5Config struct {
|
|||
Password string
|
||||
}
|
||||
|
||||
type HTTPConfig struct {
|
||||
BindAddress string
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
Device *DeviceConfig
|
||||
Routines []RoutineSpawner
|
||||
|
@ -330,6 +336,24 @@ func parseSocks5Config(section *ini.Section) (RoutineSpawner, error) {
|
|||
return config, nil
|
||||
}
|
||||
|
||||
func parseHTTPConfig(section *ini.Section) (RoutineSpawner, error) {
|
||||
config := &HTTPConfig{}
|
||||
|
||||
bindAddress, err := parseString(section, "BindAddress")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config.BindAddress = bindAddress
|
||||
|
||||
username, _ := parseString(section, "Username")
|
||||
config.Username = username
|
||||
|
||||
password, _ := parseString(section, "Password")
|
||||
config.Password = password
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
// Takes a function that parses an individual section into a config, and apply it on all
|
||||
// specified sections
|
||||
func parseRoutinesConfig(routines *[]RoutineSpawner, cfg *ini.File, sectionName string, f func(*ini.Section) (RoutineSpawner, error)) error {
|
||||
|
@ -404,6 +428,11 @@ func ParseConfig(path string) (*Configuration, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
err = parseRoutinesConfig(&routinesSpawners, cfg, "http", parseHTTPConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Configuration{
|
||||
Device: device,
|
||||
Routines: routinesSpawners,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue