2016-01-15 06:43:06 -05:00
|
|
|
// +build json
|
|
|
|
|
|
|
|
package dokodemo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
|
|
"github.com/v2ray/v2ray-core/proxy/internal/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2016-01-25 11:19:09 -05:00
|
|
|
config.RegisterInboundConfig("dokodemo-door",
|
2016-01-15 06:43:06 -05:00
|
|
|
func(data []byte) (interface{}, error) {
|
|
|
|
type DokodemoConfig struct {
|
2016-01-15 08:34:33 -05:00
|
|
|
Host *v2net.AddressJson `json:"address"`
|
|
|
|
PortValue v2net.Port `json:"port"`
|
|
|
|
NetworkList *v2net.NetworkList `json:"network"`
|
|
|
|
TimeoutValue int `json:"timeout"`
|
2016-01-15 06:43:06 -05:00
|
|
|
}
|
|
|
|
rawConfig := new(DokodemoConfig)
|
|
|
|
if err := json.Unmarshal(data, rawConfig); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &Config{
|
2016-01-15 07:17:04 -05:00
|
|
|
Address: rawConfig.Host.Address,
|
2016-01-15 06:43:06 -05:00
|
|
|
Port: rawConfig.PortValue,
|
|
|
|
Network: rawConfig.NetworkList,
|
|
|
|
Timeout: rawConfig.TimeoutValue,
|
|
|
|
}, nil
|
|
|
|
})
|
|
|
|
}
|