Skip to content

Commit

Permalink
Make Interface PreDown setting. (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
nebulosa2007 authored Dec 25, 2023
1 parent af7742b commit c862308
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions model/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ type ServerInterface struct {
ListenPort int `json:"listen_port,string"` // ,string to get listen_port string input as int
UpdatedAt time.Time `json:"updated_at"`
PostUp string `json:"post_up"`
PreDown string `json:"pre_down"`
PostDown string `json:"post_down"`
}
9 changes: 8 additions & 1 deletion templates/server.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ <h3 class="card-title">Interface</h3>
<input type="text" class="form-control" id="post_up" name="post_up"
placeholder="Post Up Script" value="{{ .serverInterface.PostUp }}">
</div>
<div class="form-group">
<label for="pre_down">Pre Down Script</label>
<input type="text" class="form-control" id="pre_down" name="pre_down"
placeholder="Pre Down Script" value="{{ .serverInterface.PreDown }}">
</div>

<div class="form-group">
<label for="post_down">Post Down Script</label>
<input type="text" class="form-control" id="post_down" name="post_down"
Expand Down Expand Up @@ -130,8 +136,9 @@ <h4 class="modal-title">KeyPair Generation</h4>
const addresses = $("#addresses").val().split(",");
const listen_port = $("#listen_port").val();
const post_up = $("#post_up").val();
const pre_down = $("#pre_down").val();
const post_down = $("#post_down").val();
const data = {"addresses": addresses, "listen_port": listen_port, "post_up": post_up, "post_down": post_down};
const data = {"addresses": addresses, "listen_port": listen_port, "post_up": post_up, "pre_down": pre_down, "post_down": post_down};

$.ajax({
cache: false,
Expand Down
1 change: 1 addition & 0 deletions templates/wg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ListenPort = {{ .serverConfig.Interface.ListenPort }}
PrivateKey = {{ .serverConfig.KeyPair.PrivateKey }}
{{if .globalSettings.MTU}}MTU = {{ .globalSettings.MTU }}{{end}}
PostUp = {{ .serverConfig.Interface.PostUp }}
PreDown = {{ .serverConfig.Interface.PreDown }}
PostDown = {{ .serverConfig.Interface.PostDown }}
Table = {{ .globalSettings.Table }}

Expand Down

0 comments on commit c862308

Please sign in to comment.