1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-17 13:05:24 +00:00
v2fly/infra/conf/http.go

36 lines
797 B
Go
Raw Normal View History

2019-02-10 18:04:11 +00:00
package conf
import (
"github.com/golang/protobuf/proto"
"v2ray.com/core/proxy/http"
)
type HttpAccount struct {
Username string `json:"user"`
Password string `json:"pass"`
}
type HttpServerConfig struct {
Timeout uint32 `json:"timeout"`
Accounts []*HttpAccount `json:"accounts"`
Transparent bool `json:"allowTransparent"`
UserLevel uint32 `json:"userLevel"`
}
func (c *HttpServerConfig) Build() (proto.Message, error) {
config := &http.ServerConfig{
Timeout: c.Timeout,
AllowTransparent: c.Transparent,
UserLevel: c.UserLevel,
}
if len(c.Accounts) > 0 {
config.Accounts = make(map[string]string)
for _, account := range c.Accounts {
config.Accounts[account.Username] = account.Password
}
}
return config, nil
}