Fixed issues mentioned in the @systemcrash review

- Reverted formatting fixes where possible
- Clarified the note about updateSearchList()
- Fixed a typo
- Made SUBNET_RANGES example yaml-friendly
- Removed Makefile
This commit is contained in:
0xCA 2023-12-04 02:28:16 +05:00
parent 8678a74bd5
commit 9e633014b5
7 changed files with 16 additions and 26 deletions

View file

@ -1,11 +0,0 @@
build-ui:
./prepare_assets.sh
build:
CGO_ENABLED=0 go build -v -ldflags="-s -w"
run:
./wireguard-ui
clean:
rm -f wireguard-ui

View file

@ -42,7 +42,7 @@ docker-compose up
| `BIND_ADDRESS` | The addresses that can access to the web interface and the port, use unix:///abspath/to/file.socket for unix domain socket. | 0.0.0.0:80 | | `BIND_ADDRESS` | The addresses that can access to the web interface and the port, use unix:///abspath/to/file.socket for unix domain socket. | 0.0.0.0:80 |
| `SESSION_SECRET` | The secret key used to encrypt the session cookies. Set this to a random value | N/A | | `SESSION_SECRET` | The secret key used to encrypt the session cookies. Set this to a random value | N/A |
| `SESSION_SECRET_FILE` | Optional filepath for the secret key used to encrypt the session cookies. Leave `SESSION_SECRET` blank to take effect | N/A | | `SESSION_SECRET_FILE` | Optional filepath for the secret key used to encrypt the session cookies. Leave `SESSION_SECRET` blank to take effect | N/A |
| `SUBNET_RANGES` | The list of address subdivision ranges. Format: `SR Name: 10.0.1.0/24; SR2: 10.0.2.0/24, 10.0.3.0/24` Each CIDR must be inside one of the server interfaces. | N/A | | `SUBNET_RANGES` | The list of address subdivision ranges. Format: `SR Name:10.0.1.0/24; SR2:10.0.2.0/24,10.0.3.0/24` Each CIDR must be inside one of the server interfaces. | N/A |
| `WGUI_USERNAME` | The username for the login page. Used for db initialization only | `admin` | | `WGUI_USERNAME` | The username for the login page. Used for db initialization only | `admin` |
| `WGUI_PASSWORD` | The password for the user on the login page. Will be hashed automatically. Used for db initialization only | `admin` | | `WGUI_PASSWORD` | The password for the user on the login page. Will be hashed automatically. Used for db initialization only | `admin` |
| `WGUI_PASSWORD_FILE` | Optional filepath for the user login password. Will be hashed automatically. Used for db initialization only. Leave `WGUI_PASSWORD` blank to take effect | N/A | | `WGUI_PASSWORD_FILE` | Optional filepath for the user login password. Will be hashed automatically. Used for db initialization only. Leave `WGUI_PASSWORD` blank to take effect | N/A |

View file

@ -385,9 +385,9 @@ func GetClient(db store.IStore) echo.HandlerFunc {
} }
qrCodeSettings := model.QRCodeSettings{ qrCodeSettings := model.QRCodeSettings{
Enabled: true, Enabled: true,
IncludeDNS: true, IncludeDNS: true,
IncludeMTU: true, IncludeMTU: true,
} }
clientData, err := db.GetClientByID(clientID, qrCodeSettings) clientData, err := db.GetClientByID(clientID, qrCodeSettings)
@ -517,9 +517,9 @@ func EmailClient(db store.IStore, mailer emailer.Emailer, emailSubject, emailCon
} }
qrCodeSettings := model.QRCodeSettings{ qrCodeSettings := model.QRCodeSettings{
Enabled: true, Enabled: true,
IncludeDNS: true, IncludeDNS: true,
IncludeMTU: true, IncludeMTU: true,
} }
clientData, err := db.GetClientByID(payload.ID, qrCodeSettings) clientData, err := db.GetClientByID(payload.ID, qrCodeSettings)
if err != nil { if err != nil {
@ -1108,6 +1108,7 @@ func ApplyServerConfig(db store.IStore, tmplDir fs.FS) echo.HandlerFunc {
} }
} }
// GetHashesChanges handler returns if database hashes have changed // GetHashesChanges handler returns if database hashes have changed
func GetHashesChanges(db store.IStore) echo.HandlerFunc { func GetHashesChanges(db store.IStore) echo.HandlerFunc {
return func(c echo.Context) error { return func(c echo.Context) error {

View file

@ -30,7 +30,7 @@ type ClientData struct {
} }
type QRCodeSettings struct { type QRCodeSettings struct {
Enabled bool Enabled bool
IncludeDNS bool IncludeDNS bool
IncludeMTU bool IncludeMTU bool
} }

View file

@ -58,13 +58,13 @@
</div> </div>
<div class="form-group form-group-sm"> <div class="form-group form-group-sm">
<select name="status-selector" id="status-selector" class="custom-select form-control-navbar" style="margin-left: 0.5em; height: 90%; font-size: 14px;"> <select name="status-selector" id="status-selector" class="custom-select form-control-navbar" style="margin-left: 0.5em; height: 90%; font-size: 14px;">
<!-- SEE updateSearchList() in clients.html BEFORE EDITING --> <!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function in clients.html BEFORE EDITING -->
<option value="All">All</option> <option value="All">All</option>
<option value="Enabled">Enabled</option> <option value="Enabled">Enabled</option>
<option value="Disabled">Disabled</option> <option value="Disabled">Disabled</option>
<option value="Connected">Connected</option> <option value="Connected">Connected</option>
<option value="Disconnected">Disconnected</option> <option value="Disconnected">Disconnected</option>
<!-- SEE updateSearchList() in clients.html BEFORE EDITING --> <!-- THIS SECTION IS OVERRIDDEN BY JS. SEE updateSearchList() function in clients.html BEFORE EDITING -->
</select> </select>
</div> </div>
</form> </form>
@ -406,7 +406,7 @@
} }
function updateApplyConfigVisibility() { function updateApplyConfigVisibility() {
$.ajax({ $.ajax({
cache: false, cache: false,
method: 'GET', method: 'GET',
url: '{{.basePath}}/test-hash', url: '{{.basePath}}/test-hash',

View file

@ -37,7 +37,7 @@ const (
DefaultDNS = "1.1.1.1" DefaultDNS = "1.1.1.1"
DefaultMTU = 1450 DefaultMTU = 1450
DefaultPersistentKeepalive = 15 DefaultPersistentKeepalive = 15
DefaultFirewallMark = "0xca6c" // i.e. 51820 DefaultFirewallMark = "0xca6c" // i.e. 51820
DefaultTable = "auto" DefaultTable = "auto"
DefaultConfigFilePath = "/etc/wireguard/wg0.conf" DefaultConfigFilePath = "/etc/wireguard/wg0.conf"
UsernameEnvVar = "WGUI_USERNAME" UsernameEnvVar = "WGUI_USERNAME"

View file

@ -429,7 +429,7 @@ func findSubnetRangeForIP(cidr string) (uint16, error) {
} }
} }
} }
return 0, fmt.Errorf("Subnet range not foud for this IP") return 0, fmt.Errorf("Subnet range not found for this IP")
} }
// FillClientSubnetRange to fill subnet ranges client belongs to, does nothing if SRs are not found // FillClientSubnetRange to fill subnet ranges client belongs to, does nothing if SRs are not found