mirror of
https://github.com/ngoduykhanh/wireguard-ui
synced 2024-05-28 11:32:55 +02:00
Add ForwardMark to global settings
This commit is contained in:
parent
ad4ca4d9bb
commit
f6720d2723
|
@ -10,6 +10,7 @@ type GlobalSetting struct {
|
|||
DNSServers []string `json:"dns_servers"`
|
||||
MTU int `json:"mtu,string"`
|
||||
PersistentKeepalive int `json:"persistent_keepalive,string"`
|
||||
ForwardMark string `json:"forward_mark"`
|
||||
ConfigFilePath string `json:"config_file_path"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
|
|
@ -90,6 +90,7 @@ func (o *JsonDB) Init() error {
|
|||
globalSetting.DNSServers = []string{util.DefaultDNS}
|
||||
globalSetting.MTU = util.DefaultMTU
|
||||
globalSetting.PersistentKeepalive = util.DefaultPersistentKeepalive
|
||||
globalSetting.ForwardMark = util.DefaultForwardMark
|
||||
globalSetting.ConfigFilePath = util.DefaultConfigFilePath
|
||||
globalSetting.UpdatedAt = time.Now().UTC()
|
||||
o.conn.Write("server", "global_settings", globalSetting)
|
||||
|
|
|
@ -55,6 +55,12 @@ Global Settings
|
|||
name="persistent_keepalive" placeholder="Persistent Keepalive"
|
||||
value="{{if .globalSettings.PersistentKeepalive }}{{ .globalSettings.PersistentKeepalive }}{{end}}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="forward_mark">Forward Mark</label>
|
||||
<input type="text" class="form-control" id="forward_mark"
|
||||
name="forward_mark" placeholder="Forward Mark"
|
||||
value="{{ .globalSettings.ForwardMark }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="config_file_path">Wireguard Config File Path</label>
|
||||
<input type="text" class="form-control" id="config_file_path"
|
||||
|
@ -141,8 +147,9 @@ Global Settings
|
|||
const dns_servers = $("#dns_servers").val().split(",");
|
||||
const mtu = $("#mtu").val();
|
||||
const persistent_keepalive = $("#persistent_keepalive").val();
|
||||
const forward_mark = $("#forward_mark").val();
|
||||
const config_file_path = $("#config_file_path").val();
|
||||
const data = {"endpoint_address": endpoint_address, "dns_servers": dns_servers, "mtu": mtu, "persistent_keepalive": persistent_keepalive, "config_file_path": config_file_path};
|
||||
const data = {"endpoint_address": endpoint_address, "dns_servers": dns_servers, "mtu": mtu, "persistent_keepalive": persistent_keepalive, "forward_mark": forward_mark, "config_file_path": config_file_path};
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
|
@ -211,6 +218,9 @@ Global Settings
|
|||
},
|
||||
config_file_path: {
|
||||
required: true
|
||||
},
|
||||
forward_mark: {
|
||||
required: false
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
|
@ -255,4 +265,4 @@ Global Settings
|
|||
});
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
|
|
@ -26,6 +26,7 @@ const (
|
|||
DefaultDNS = "1.1.1.1"
|
||||
DefaultMTU = 1450
|
||||
DefaultPersistentKeepalive = 15
|
||||
DefaultForwardMark = "0xca6c"
|
||||
DefaultConfigFilePath = "/etc/wireguard/wg0.conf"
|
||||
UsernameEnvVar = "WGUI_USERNAME"
|
||||
PasswordEnvVar = "WGUI_PASSWORD"
|
||||
|
|
|
@ -55,11 +55,17 @@ func BuildClientConfig(client model.Client, server model.Server, setting model.G
|
|||
peerPersistentKeepalive = fmt.Sprintf("PersistentKeepalive = %d\n", setting.PersistentKeepalive)
|
||||
}
|
||||
|
||||
forwardMark := ""
|
||||
if setting.ForwardMark != DefaultForwardMark {
|
||||
forwardMark = fmt.Sprintf("FwMark = %s\n", setting.ForwardMark)
|
||||
}
|
||||
|
||||
// build the config as string
|
||||
strConfig := "[Interface]\n" +
|
||||
clientAddress +
|
||||
clientPrivateKey +
|
||||
clientDNS +
|
||||
forwardMark +
|
||||
"\n[Peer]\n" +
|
||||
peerPublicKey +
|
||||
peerPresharedKey +
|
||||
|
|
Loading…
Reference in a new issue