mirror of
https://github.com/h44z/wg-portal.git
synced 2025-09-13 14:31:15 +00:00
more ui improvements, fix peer template for clients
This commit is contained in:
@@ -106,7 +106,7 @@ func NewConfig() *Config {
|
||||
cfg.LDAP.DisabledAttribute = "userAccountControl"
|
||||
cfg.LDAP.AdminLdapGroup = "CN=WireGuardAdmins,OU=_O_IT,DC=COMPANY,DC=LOCAL"
|
||||
|
||||
cfg.WG.DeviceNames = []string{"wg0", "wg1"}
|
||||
cfg.WG.DeviceNames = []string{"wg0"}
|
||||
cfg.WG.DefaultDeviceName = "wg0"
|
||||
cfg.WG.ConfigDirectoryPath = "/etc/wireguard"
|
||||
cfg.WG.ManageIPAddresses = true
|
||||
|
@@ -574,39 +574,7 @@ func (m *PeerManager) GetFilteredAndSortedPeers(device, sortKey, sortDirection,
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(filteredPeers, func(i, j int) bool {
|
||||
var sortValueLeft string
|
||||
var sortValueRight string
|
||||
|
||||
switch sortKey {
|
||||
case "id":
|
||||
sortValueLeft = filteredPeers[i].Identifier
|
||||
sortValueRight = filteredPeers[j].Identifier
|
||||
case "pubKey":
|
||||
sortValueLeft = filteredPeers[i].PublicKey
|
||||
sortValueRight = filteredPeers[j].PublicKey
|
||||
case "mail":
|
||||
sortValueLeft = filteredPeers[i].Email
|
||||
sortValueRight = filteredPeers[j].Email
|
||||
case "ip":
|
||||
sortValueLeft = filteredPeers[i].IPsStr
|
||||
sortValueRight = filteredPeers[j].IPsStr
|
||||
case "handshake":
|
||||
if filteredPeers[i].Peer == nil {
|
||||
return false
|
||||
} else if filteredPeers[j].Peer == nil {
|
||||
return true
|
||||
}
|
||||
sortValueLeft = filteredPeers[i].Peer.LastHandshakeTime.Format(time.RFC3339)
|
||||
sortValueRight = filteredPeers[j].Peer.LastHandshakeTime.Format(time.RFC3339)
|
||||
}
|
||||
|
||||
if sortDirection == "asc" {
|
||||
return sortValueLeft < sortValueRight
|
||||
} else {
|
||||
return sortValueLeft > sortValueRight
|
||||
}
|
||||
})
|
||||
sortPeers(sortKey, sortDirection, filteredPeers)
|
||||
|
||||
return filteredPeers
|
||||
}
|
||||
@@ -619,6 +587,12 @@ func (m *PeerManager) GetSortedPeersForEmail(sortKey, sortDirection, email strin
|
||||
m.populatePeerData(&peers[i])
|
||||
}
|
||||
|
||||
sortPeers(sortKey, sortDirection, peers)
|
||||
|
||||
return peers
|
||||
}
|
||||
|
||||
func sortPeers(sortKey string, sortDirection string, peers []Peer) {
|
||||
sort.Slice(peers, func(i, j int) bool {
|
||||
var sortValueLeft string
|
||||
var sortValueRight string
|
||||
@@ -636,6 +610,9 @@ func (m *PeerManager) GetSortedPeersForEmail(sortKey, sortDirection, email strin
|
||||
case "ip":
|
||||
sortValueLeft = peers[i].IPsStr
|
||||
sortValueRight = peers[j].IPsStr
|
||||
case "endpoint":
|
||||
sortValueLeft = peers[i].Endpoint
|
||||
sortValueRight = peers[j].Endpoint
|
||||
case "handshake":
|
||||
if peers[i].Peer == nil {
|
||||
return true
|
||||
@@ -652,8 +629,6 @@ func (m *PeerManager) GetSortedPeersForEmail(sortKey, sortDirection, email strin
|
||||
return sortValueLeft > sortValueRight
|
||||
}
|
||||
})
|
||||
|
||||
return peers
|
||||
}
|
||||
|
||||
func (m *PeerManager) GetDevice(device string) Device {
|
||||
|
@@ -17,7 +17,7 @@ MTU = {{.Peer.Mtu}}
|
||||
{{- end}}
|
||||
|
||||
[Peer]
|
||||
PublicKey = {{ .Peer.PublicKey }}
|
||||
PublicKey = {{ .Interface.PublicKey }}
|
||||
Endpoint = {{ .Peer.Endpoint }}
|
||||
{{- if .Peer.AllowedIPsStr}}
|
||||
AllowedIPs = {{ .Peer.AllowedIPsStr }}
|
||||
|
Reference in New Issue
Block a user