github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/components/config/default.go (about)

     1  package config
     2  
     3  import (
     4  	"path/filepath"
     5  
     6  	"github.com/Asutorufa/yuhaiin/pkg/protos/config"
     7  	"github.com/Asutorufa/yuhaiin/pkg/protos/config/bypass"
     8  	pd "github.com/Asutorufa/yuhaiin/pkg/protos/config/dns"
     9  	"github.com/Asutorufa/yuhaiin/pkg/protos/config/listener"
    10  	pl "github.com/Asutorufa/yuhaiin/pkg/protos/config/log"
    11  )
    12  
    13  func defaultSetting(path string) *config.Setting {
    14  	return &config.Setting{
    15  		Ipv6:         false,
    16  		NetInterface: "",
    17  		SystemProxy: &config.SystemProxy{
    18  			Http:   true,
    19  			Socks5: false,
    20  			// linux system set socks5 will make firfox websocket can't connect
    21  			// https://askubuntu.com/questions/890274/slack-desktop-client-on-16-04-behind-proxy-server
    22  		},
    23  		Bypass: &bypass.BypassConfig{
    24  			Tcp:        bypass.Mode_bypass,
    25  			Udp:        bypass.Mode_bypass,
    26  			BypassFile: filepath.Join(filepath.Dir(path), "yuhaiin.conf"),
    27  			CustomRuleV3: []*bypass.ModeConfig{
    28  				{
    29  					Hostname: []string{"dns.google"},
    30  					Mode:     bypass.Mode_proxy,
    31  					Tag:      "remote_dns",
    32  				},
    33  				{
    34  					Hostname: []string{
    35  						"223.5.5.5",
    36  					},
    37  					Mode: bypass.Mode_direct,
    38  				},
    39  				{
    40  					Hostname: []string{
    41  						"example.block.domain.com",
    42  					},
    43  					Mode: bypass.Mode_block,
    44  				},
    45  			},
    46  		},
    47  		Dns: &pd.DnsConfig{
    48  			ResolveRemoteDomain: false,
    49  			Server:              "127.0.0.1:5353",
    50  			Fakedns:             false,
    51  			FakednsIpRange:      "10.0.2.1/16",
    52  			FakednsIpv6Range:    "fc00::/64",
    53  			FakednsWhitelist: []string{
    54  				"*.msftncsi.com",
    55  				"*.msftconnecttest.com",
    56  				"ping.archlinux.org",
    57  			},
    58  			Local: &pd.Dns{
    59  				Host: "223.5.5.5",
    60  				Type: pd.Type_doh,
    61  			},
    62  			Remote: &pd.Dns{
    63  				Host: "dns.google",
    64  				Type: pd.Type_doh,
    65  			},
    66  			Bootstrap: &pd.Dns{
    67  				Host: "223.5.5.5",
    68  				Type: pd.Type_udp,
    69  			},
    70  			Resolver: map[string]*pd.Dns{
    71  				"local": {
    72  					Host: "223.5.5.5",
    73  					Type: pd.Type_doh,
    74  				},
    75  				"remote": {
    76  					Host: "dns.google",
    77  					Type: pd.Type_doh,
    78  				},
    79  				"bootstrap": {
    80  					Host: "223.5.5.5",
    81  					Type: pd.Type_udp,
    82  				},
    83  			},
    84  			Hosts: map[string]string{"example.com": "example.com"},
    85  		},
    86  		Logcat: &pl.Logcat{
    87  			Level: pl.LogLevel_debug,
    88  			Save:  true,
    89  		},
    90  
    91  		Server: &listener.InboundConfig{
    92  			HijackDns:       true,
    93  			HijackDnsFakeip: true,
    94  			Inbounds: map[string]*listener.Inbound{
    95  				"mixed": {
    96  					Name:    "mixed",
    97  					Enabled: true,
    98  					Network: &listener.Inbound_Tcpudp{
    99  						Tcpudp: &listener.Tcpudp{
   100  							Host:    "127.0.0.1:1080",
   101  							Control: listener.TcpUdpControl_tcp_udp_control_all,
   102  						},
   103  					},
   104  					Protocol: &listener.Inbound_Mix{
   105  						Mix: &listener.Mixed{},
   106  					},
   107  				},
   108  				"tun": {
   109  					Name:    "tun",
   110  					Enabled: false,
   111  					Network: &listener.Inbound_Empty{Empty: &listener.Empty{}},
   112  					Protocol: &listener.Inbound_Tun{
   113  						Tun: &listener.Tun{
   114  							Name:          "tun://tun0",
   115  							Mtu:           9000,
   116  							Portal:        "172.19.0.1/24",
   117  							PortalV6:      "fdfe:dcba:9876::1/64",
   118  							SkipMulticast: true,
   119  							Driver:        listener.Tun_system_gvisor,
   120  							Route: &listener.Route{
   121  								Routes: []string{
   122  									"10.0.2.1/16",
   123  									"fc00::/64",
   124  								},
   125  							},
   126  						},
   127  					},
   128  				},
   129  				"yuubinsya": {
   130  					Name:    "yuubinsya",
   131  					Enabled: false,
   132  					Network: &listener.Inbound_Tcpudp{
   133  						Tcpudp: &listener.Tcpudp{
   134  							Host:    "127.0.0.1:40501",
   135  							Control: listener.TcpUdpControl_disable_udp,
   136  						},
   137  					},
   138  					Protocol: &listener.Inbound_Yuubinsya{
   139  						Yuubinsya: &listener.Yuubinsya{
   140  							Password: "password",
   141  						},
   142  					},
   143  				},
   144  			},
   145  			Servers: map[string]*listener.Protocol{},
   146  		},
   147  	}
   148  }