Skip to content

Commit

Permalink
Clearer configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
Kioubit committed Feb 27, 2023
1 parent c1647ed commit 4b240e1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 27 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module pndpd
go 1.18

require (
golang.org/x/net v0.0.0-20220225172249-27dd8689420f
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
golang.org/x/net v0.7.0
golang.org/x/sys v0.5.0
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
var Version = "Custom_Build"

func main() {
fmt.Println("PNDPD Version", Version, "- Kioubit 2022")
fmt.Println("PNDPD Version", Version, "- Kioubit")

if len(os.Args) <= 2 {
printUsage()
Expand Down
34 changes: 23 additions & 11 deletions modules/userInterface/userInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import (
func init() {
commands := []modules.Command{{
CommandText: "proxy",
Description: "pndpd proxy <interface1> <interface2> <optional whitelist of CIDRs separated by a semicolon applied to interface2>",
Description: "pndpd proxy <external interface> <internal interface> <[optional] 'auto' to determine filters from the external interface or whitelist of CIDRs separated by a semicolon>",
BlockTerminate: true,
ConfigEnabled: true,
CommandLineEnabled: true,
}, {
CommandText: "responder",
Description: "pndpd responder <interface> <optional whitelist of CIDRs separated by a semicolon>",
Description: "pndpd responder <external interface> <[optional] 'auto' to determine filters from the internal interface or whitelist of CIDRs separated by a semicolon>",
BlockTerminate: true,
ConfigEnabled: true,
CommandLineEnabled: true,
Expand Down Expand Up @@ -58,11 +58,17 @@ func initCallback(callback modules.CallbackInfo) {
case "proxy":
switch len(callback.Arguments) {
case 3:
var filter = callback.Arguments[2]
var autosense = ""
if callback.Arguments[2] == "auto" {
filter = ""
autosense = callback.Arguments[1]
}
allProxies = append(allProxies, &configProxy{
Iface1: callback.Arguments[0],
Iface2: callback.Arguments[1],
Filter: callback.Arguments[2],
autosense: "",
Filter: filter,
autosense: autosense,
instance: nil,
})
case 2:
Expand All @@ -78,10 +84,16 @@ func initCallback(callback modules.CallbackInfo) {
}
case "responder":
if len(callback.Arguments) == 2 {
var filter = callback.Arguments[1]
var autosense = ""
if callback.Arguments[1] == "auto" {
filter = ""
autosense = callback.Arguments[0]
}
allResponders = append(allResponders, &configResponder{
Iface: callback.Arguments[0],
Filter: callback.Arguments[1],
autosense: "",
Filter: filter,
autosense: autosense,
instance: nil,
})
} else {
Expand Down Expand Up @@ -109,11 +121,11 @@ func initCallback(callback modules.CallbackInfo) {
obj := configProxy{}
filter := ""
for _, n := range callback.Arguments {
if strings.HasPrefix(n, "iface1") {
obj.Iface1 = strings.TrimSpace(strings.TrimPrefix(n, "iface1"))
if strings.HasPrefix(n, "ext-iface") {
obj.Iface1 = strings.TrimSpace(strings.TrimPrefix(n, "ext-iface"))
}
if strings.HasPrefix(n, "iface2") {
obj.Iface2 = strings.TrimSpace(strings.TrimPrefix(n, "iface2"))
if strings.HasPrefix(n, "int-iface") {
obj.Iface2 = strings.TrimSpace(strings.TrimPrefix(n, "int-iface"))
}
if strings.HasPrefix(n, "filter") {
filter += strings.TrimSpace(strings.TrimPrefix(n, "filter")) + ";"
Expand All @@ -133,7 +145,7 @@ func initCallback(callback modules.CallbackInfo) {
showError("config: cannot have both a filter and autosense enabled on a proxy object")
}
if obj.Iface2 == "" || obj.Iface1 == "" {
showError("config: two interfaces need to be specified in the config file for a proxy object. (iface1 and iface2 parameters)")
showError("config: two interfaces need to be specified in the config file for a proxy object. (ext-iface and int-iface parameters)")
}
allProxies = append(allProxies, &obj)
case "responder":
Expand Down
18 changes: 9 additions & 9 deletions pndpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ responder {
}

// Proxy example
// Create an NDP proxy for proxying NDP between iface1 ("eth0") and iface2 ("eth1")
// The whitelist is applied on iface2
// Create an NDP proxy for proxying NDP between the external ext-iface ("eth0") and the internal int-iface ("eth1")
proxy {
iface1 eth0
iface2 eth1
ext-iface eth0
int-iface eth1
filter fd01::/64
filter fd02::/64
}


// Responder example with autoconfigured whitelist
// The whitelist is configured based on the addresses assigned to the interface specified. This works even if the IP addresses change frequently.
// The whitelist is configured based on the addresses assigned to the interface specified via the autosense parameter.
// This works even if the IP addresses change frequently.
responder {
iface eth0
autosense eth0
}

// Proxy example with autoconfigured whitelist
// The whitelist is configured based on the addresses assigned to the interface specified. This works even if the IP addresses change frequently.
// The whitelist is applied to iface2
// The whitelist is configured based on the addresses assigned to the interface specified via the autosense parameter.
// This works even if the IP addresses change frequently.
proxy {
iface1 eth0
iface2 eth1
ext-iface eth0
int-iface eth1
autosense eth1
}

0 comments on commit 4b240e1

Please sign in to comment.