mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-05-24 00:24:06 +03:00
Get Endpoint Address for suggestion form
This commit is contained in:
parent
deecd9c267
commit
85e466698f
7 changed files with 164 additions and 2 deletions
|
@ -281,3 +281,25 @@ func GlobalSettingSubmit() echo.HandlerFunc {
|
|||
return c.JSON(http.StatusOK, jsonHTTPResponse{true, "Updated global settings successfully"})
|
||||
}
|
||||
}
|
||||
|
||||
// MachineIPAddresses handler to get local interface ip addresses
|
||||
func MachineIPAddresses() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
// get private ip addresses
|
||||
interfaceList, err := util.GetInterfaceIPs()
|
||||
if err != nil {
|
||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot get machine ip addresses"})
|
||||
}
|
||||
|
||||
// get public ip address
|
||||
// TODO: Remove the go-external-ip dependency
|
||||
publicInterface, err := util.GetPublicIP()
|
||||
if err != nil {
|
||||
log.Warn("Cannot get machine public ip address: ", err)
|
||||
} else {
|
||||
interfaceList = append(interfaceList, publicInterface)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, interfaceList)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue