Simulation base code

This commit is contained in:
2025-05-30 16:23:39 +01:00
parent 2d55643dd9
commit a46ec3575c
7 changed files with 271 additions and 176 deletions

View File

@@ -42,6 +42,8 @@ type IP struct {
Query string
}
var Test = false
// ReadIpTable Read data from Ip tables from json file
func ReadIpTable() (*IpAddresses, error) {
// Get Path from config
@@ -178,6 +180,16 @@ func (table *IpAddresses) RemoveDuplicates() error {
// CurrentPublicIP Get Current Public IP address
func CurrentPublicIP() (string, error) {
// Get configs
Config, err := config.ConfigInit(nil, nil)
if err != nil {
return "", err
}
// If test mode is on then return local address
if Config.Test {
return "0.0.0.0", nil
}
req, err := http.Get("http://ip-api.com/json/")
if err != nil {
return "", err