forked from shawn1m/overture
-
Notifications
You must be signed in to change notification settings - Fork 43
/
init.go
47 lines (37 loc) · 1.37 KB
/
init.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2016 shawn1m. All rights reserved.
// Use of this source code is governed by The MIT License (MIT) that can be
// found in the LICENSE file.
// Package core implements the essential features.
package core
import (
"github.com/shadowsocks/overture/core/config"
"github.com/shadowsocks/overture/core/inbound"
"github.com/shadowsocks/overture/core/outbound"
"github.com/shadowsocks/overture/core/utils"
)
// Initiate the server with config file
func InitServer(configFilePath string, vpnMode bool) {
config := config.NewConfig(configFilePath)
// New dispatcher without ClientBundle, ClientBundle must be initiated when server is running
d := outbound.Dispatcher{
PrimaryDNS: config.PrimaryDNS,
AlternativeDNS: config.AlternativeDNS,
OnlyPrimaryDNS: config.OnlyPrimaryDNS,
IPNetworkPrimaryList: config.IPNetworkPrimaryList,
IPNetworkAlternativeList: config.IPNetworkAlternativeList,
DomainPrimaryList: config.DomainPrimaryList,
DomainAlternativeList: config.DomainAlternativeList,
RedirectIPv6Record: config.IPv6UseAlternativeDNS,
MinimumTTL: config.MinimumTTL,
Hosts: config.Hosts,
Cache: config.Cache,
}
s := &inbound.Server{
BindAddress: config.BindAddress,
HTTPAddress: config.HTTPAddress,
Dispatcher: d,
RejectQtype: config.RejectQtype,
}
utils.VpnMode = vpnMode
s.Run()
}