From f107b7e40809fef265b4cda52bcdcf7c1c56b684 Mon Sep 17 00:00:00 2001 From: Hu Jun Date: Sun, 20 Aug 2023 12:09:11 -0700 Subject: [PATCH] bump up shouchan to latest --- go.mod | 6 +- zouppp.go | 188 +----------------------------------------------------- 2 files changed, 4 insertions(+), 190 deletions(-) diff --git a/go.mod b/go.mod index 6563f05..38a3c25 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/hujun-open/etherconn v0.6.1 github.com/hujun-open/myaddr v0.1.1 github.com/hujun-open/mywg v0.2.0 - github.com/hujun-open/shouchan v0.2.0 + github.com/hujun-open/shouchan v0.3.4 github.com/insomniacslk/dhcp v0.0.0-20220504074936-1ca156eafb9f github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8 github.com/vishvananda/netlink v1.1.0 @@ -17,8 +17,8 @@ require ( github.com/asavie/xdp v0.3.4-0.20211113171712-711132ccc429 // indirect github.com/cilium/ebpf v0.8.1 // indirect github.com/google/gopacket v1.1.19 // indirect - github.com/hujun-open/extyaml v0.3.0 // indirect - github.com/hujun-open/myflags v0.1.2 // indirect + github.com/hujun-open/extyaml v0.4.0 // indirect + github.com/hujun-open/myflags v0.3.2 // indirect github.com/safchain/ethtool v0.2.0 // indirect github.com/u-root/uio v0.0.0-20220204230159-dac05f7d2cb4 // indirect github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect diff --git a/zouppp.go b/zouppp.go index 726e31a..ba66810 100644 --- a/zouppp.go +++ b/zouppp.go @@ -37,195 +37,9 @@ import ( "github.com/hujun-open/zouppp/pppoe" ) -// func newSetupviaFlags( -// Ifname string, -// NumOfClients uint, -// retry uint, -// timeout time.Duration, -// StartMAC string, -// MacStep uint, -// vlan int, -// vlanetype uint, -// svlan int, -// svlanetype uint, -// VLANStep uint, -// excludevlanid string, -// Interval time.Duration, -// logl uint, -// rid, cid string, -// uname, passwd string, -// usepap bool, -// v4, v6 bool, -// dhcpv6iana, dhcpv6iapd bool, -// pppifname string, -// Apply bool, -// rootlog *zap.Logger, -// ) (*client.Setup, error) { -// var r client.Setup -// var err error -// // r.Logger = rootlog -// if Ifname == "" { -// return nil, fmt.Errorf("interface name can't be empty") -// } -// if NumOfClients == 0 { -// return nil, fmt.Errorf("number of clients can't be zero") -// } -// iff, err := net.InterfaceByName(Ifname) -// if err != nil { -// return nil, fmt.Errorf("can't find interface %v,%w", Ifname, err) -// } -// r.Ifname = Ifname -// if NumOfClients == 0 { -// return nil, fmt.Errorf("number of client is 0") -// } -// r.NumOfClients = NumOfClients -// if StartMAC == "" { -// r.StartMAC = iff.HardwareAddr -// } else { -// r.StartMAC, err = net.ParseMAC(StartMAC) -// if err != nil { -// return nil, err -// } -// } -// r.MacStep = MacStep -// r.Retry = retry -// r.Timeout = timeout -// chkVIDFunc := func(vid int) bool { -// if vid < 0 || vid > 4095 { -// return false -// } -// return true -// } - -// newvlanFunc := func(id int, etype uint) *etherconn.VLAN { -// if id >= 0 { -// return ðerconn.VLAN{ -// ID: uint16(id), -// EtherType: uint16(etype), -// } -// } -// return nil -// } -// if chkVIDFunc(vlan) { -// r.StartVLANs = etherconn.VLANs{} -// if v := newvlanFunc(vlan, vlanetype); v != nil { -// r.StartVLANs = append(r.StartVLANs, v) -// } -// if chkVIDFunc(svlan) { -// if v := newvlanFunc(svlan, svlanetype); v != nil { -// r.StartVLANs = append(etherconn.VLANs{v}, r.StartVLANs...) -// } -// } - -// } else { -// if chkVIDFunc(svlan) { -// return nil, fmt.Errorf("spcifying svlan also require specifying a valid vlan") -// } -// } - -// r.VLANStep = VLANStep -// strToExtListFunc := func(exts string) []uint16 { -// vidstrList := strings.Split(exts, ",") -// r := []uint16{} -// for _, vidstr := range vidstrList { -// vid, err := strconv.Atoi(vidstr) -// if err == nil { -// if vid >= 0 && vid <= 4095 { -// r = append(r, uint16(vid)) -// } -// } -// } -// return r -// } -// r.ExcludedVLANs = strToExtListFunc(excludevlanid) -// r.Interval = Interval -// r.LogLevel = client.LoggingLvl(logl) -// r.RID = rid -// r.CID = cid -// r.UserName = uname -// r.Password = passwd -// r.AuthProto = lcp.ProtoCHAP -// if usepap { -// r.AuthProto = lcp.ProtoPAP -// } -// r.IPv4 = v4 -// r.IPv6 = v6 -// r.DHCPv6IANA = dhcpv6iana -// r.DHCPv6IAPD = dhcpv6iapd -// r.Apply = Apply -// if !strings.Contains(pppifname, client.VarName) { -// return nil, fmt.Errorf("ppp interface name must contain %v", client.VarName) -// } -// r.PPPIfName = pppifname -// r.ResultCh = make(chan *client.DialResult, resultChannelDepth) -// r.StopResultCh = make(chan struct{}) -// return &r, nil -// } - func main() { - // ifname := flag.String("i", "", "interface name") - // loglvl := flag.Uint("l", uint(client.LogLvlErr), fmt.Sprintf("log level: %d,%d,%d", client.LogLvlErr, client.LogLvlInfo, client.LogLvlDebug)) - // mac := flag.String("mac", "", "mac address") - // macstep := flag.Uint("macstep", 1, "mac address step") - // vlanstep := flag.Uint("vlanstep", 0, "VLAN Id step") - // clntnum := flag.Uint("n", 1, "number of clients") - // uname := flag.String("u", "", "user name") - // passwd := flag.String("p", "", "password") - // usepap := flag.Bool("pap", false, "use PAP instead of CHAP") - // cid := flag.String("cid", "", "pppoe BBF tag circuit-id") - // rid := flag.String("rid", "", "pppoe BBF tag remote-id") - // ipv4 := flag.Bool("v4", true, "enable Ipv4") - // ipv6 := flag.Bool("v6", true, "enable Ipv6") - // dhcp6iana := flag.Bool("dhcp6iana", false, "request IANA via running dhcpv6 over ppp") - // dhcp6iapd := flag.Bool("dhcp6iapd", false, "request IAPD via running dhcpv6 over ppp") - // vlanid := flag.Int("vlan", -1, "vlan tag") - // vlantype := flag.Uint("vlanetype", 0x8100, "vlan tag EtherType") - // svlanid := flag.Int("svlan", -1, "svlan tag") - // svlantype := flag.Uint("svlanetype", 0x8100, "svlan tag EtherType") - // profiling := flag.Bool("profiling", false, "enable profiling, only for dev use") - // excludevlanid := flag.String("excludedvlans", "", "excluded vlan IDs") - // retry := flag.Uint("retry", 3, "number of retry") - // timeout := flag.Duration("timeout", 5*time.Second, "timeout") - // interval := flag.Duration("interval", time.Millisecond, "interval between launching client") - // pppifname := flag.String("pppif", client.DefaultPPPIfNameTemplate, fmt.Sprintf("ppp interface name, must contain %v", client.VarName)) - // usexdp := flag.Bool("xdp", false, "use XDP") - // apply := flag.Bool("a", false, "apply the network config, set false to skip creating the PPP TUN if") - // flag.Parse() - // rootlog, err := client.NewDefaultZouPPPLogger(client.LoggingLvl(*loglvl)) - // if err != nil { - // log.Fatalf("failed to create logger, %v", err) - // } - // // getting setup from flags - // setup, err := newSetupviaFlags( - // *ifname, - // *clntnum, - // *retry, - // *timeout, - // *mac, - // *macstep, - // *vlanid, - // *vlantype, - // *svlanid, - // *svlantype, - // *vlanstep, - // *excludevlanid, - // *interval, - // *loglvl, - // // *debug, - // *rid, *cid, - // *uname, *passwd, - // *usepap, - // *ipv4, *ipv6, *dhcp6iana, *dhcp6iapd, - // *pppifname, - // *apply, - // rootlog, - // ) - // if err != nil { - // log.Fatalf("invalid parameter, %v", err) - // } - setup := client.DefaultSetup() - cnf, err := shouchan.NewSConfCMDLine(setup, "") + cnf, err := shouchan.NewSConf(setup, "zouppp", "a pppoe testing tool", shouchan.WithDefaultConfigFilePath[*client.Setup]("zouppp.conf")) if err != nil { log.Fatalf("failed to create configuration, %v", err) }