测试2
This commit is contained in:
parent
95834d2324
commit
f8d4727c2b
14
tap.go
14
tap.go
|
@ -3,7 +3,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
"os/exec"
|
||||||
gen "slimming/proto/gen"
|
gen "slimming/proto/gen"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/songgao/packets/ethernet"
|
"github.com/songgao/packets/ethernet"
|
||||||
|
@ -67,6 +69,17 @@ func (nc *NetCard) Run() {
|
||||||
go nc.runRead()
|
go nc.runRead()
|
||||||
go nc.runWrite()
|
go nc.runWrite()
|
||||||
// go nc.cli.run()
|
// go nc.cli.run()
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
cmd := strings.Split("addr add 10.10.10.10/24 dev stap", " ")
|
||||||
|
err := exec.Command(cmd[0], cmd[1:]...).Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
cmd = strings.Split("ip link set dev stap up", " ")
|
||||||
|
err = exec.Command(cmd[0], cmd[1:]...).Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
nc.server.run()
|
nc.server.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,6 +122,7 @@ func (nc *NetCard) runRead() {
|
||||||
framesBytes = append(framesBytes, []byte(rframe))
|
framesBytes = append(framesBytes, []byte(rframe))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println(len(framesBytes))
|
||||||
if len(framesBytes) > 0 {
|
if len(framesBytes) > 0 {
|
||||||
if nc.cli.conn == nil {
|
if nc.cli.conn == nil {
|
||||||
nc.cli.connect()
|
nc.cli.connect()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user