mirror of
https://github.com/h44z/wg-portal.git
synced 2025-08-25 14:31:14 +00:00
WIP: support different interface types: server, client and custom. Show different UI for each type.
This commit is contained in:
@@ -45,10 +45,10 @@ func (s *Server) PostAdminEditInterface(c *gin.Context) {
|
||||
}
|
||||
// Clean list input
|
||||
formDevice.IPs = common.ParseStringList(formDevice.IPsStr)
|
||||
formDevice.AllowedIPs = common.ParseStringList(formDevice.AllowedIPsStr)
|
||||
formDevice.DefaultAllowedIPs = common.ParseStringList(formDevice.DefaultAllowedIPsStr)
|
||||
formDevice.DNS = common.ParseStringList(formDevice.DNSStr)
|
||||
formDevice.IPsStr = common.ListToString(formDevice.IPs)
|
||||
formDevice.AllowedIPsStr = common.ListToString(formDevice.AllowedIPs)
|
||||
formDevice.DefaultAllowedIPsStr = common.ListToString(formDevice.DefaultAllowedIPs)
|
||||
formDevice.DNSStr = common.ListToString(formDevice.DNS)
|
||||
|
||||
// Update WireGuard device
|
||||
@@ -122,8 +122,8 @@ func (s *Server) GetApplyGlobalConfig(c *gin.Context) {
|
||||
peers := s.peers.GetAllPeers(device.DeviceName)
|
||||
|
||||
for _, peer := range peers {
|
||||
peer.AllowedIPs = device.AllowedIPs
|
||||
peer.AllowedIPsStr = device.AllowedIPsStr
|
||||
peer.AllowedIPs = device.DefaultAllowedIPs
|
||||
peer.AllowedIPsStr = device.DefaultAllowedIPsStr
|
||||
if err := s.peers.UpdatePeer(peer); err != nil {
|
||||
SetFlashMessage(c, err.Error(), "danger")
|
||||
c.Redirect(http.StatusSeeOther, "/admin/device/edit")
|
||||
|
@@ -23,7 +23,7 @@ func (s *Server) PrepareNewPeer(device string) (wireguard.Peer, error) {
|
||||
|
||||
peer := wireguard.Peer{}
|
||||
peer.IsNew = true
|
||||
peer.AllowedIPsStr = dev.AllowedIPsStr
|
||||
peer.AllowedIPsStr = dev.DefaultAllowedIPsStr
|
||||
peer.IPs = make([]string, len(dev.IPs))
|
||||
for i := range dev.IPs {
|
||||
freeIP, err := s.peers.GetAvailableIp(device, dev.IPs[i])
|
||||
@@ -77,7 +77,7 @@ func (s *Server) CreatePeerByEmail(device, email, identifierSuffix string, disab
|
||||
// This function also configures the new peer on the physical WireGuard interface if the peer is not deactivated.
|
||||
func (s *Server) CreatePeer(device string, peer wireguard.Peer) error {
|
||||
dev := s.peers.GetDevice(device)
|
||||
peer.AllowedIPsStr = dev.AllowedIPsStr
|
||||
peer.AllowedIPsStr = dev.DefaultAllowedIPsStr
|
||||
if peer.IPs == nil || len(peer.IPs) == 0 {
|
||||
peer.IPs = make([]string, len(dev.IPs))
|
||||
for i := range dev.IPs {
|
||||
|
Reference in New Issue
Block a user