Browse Source

working release

master
Samuel Pua 5 years ago
parent
commit
571b5ecdc8
  1. 1
      .gitignore
  2. 1
      down-six.sh
  3. 65
      main.go
  4. BIN
      sixes-to-fours
  5. 8
      up-six.sh.example

1
.gitignore

@ -0,0 +1 @@
up-six.sh

1
down-six.sh

@ -0,0 +1 @@
ip link del he-ipv6

65
main.go

@ -0,0 +1,65 @@
package main
import (
"fmt"
"log"
"os/exec"
"io/ioutil"
"strings"
"math/rand"
"time"
)
const (
upFile = "up-six.sh"
downFile = "down-six.sh"
repeatTimer = 120
)
func main() {
for true {
fileToExec(downFile)
fileToExec(upFile)
time.Sleep(repeatTimer * time.Second)
}
}
func fileToExec(filename string) {
doCmds := fileToCmd(filename)
for _, currCmd := range doCmds {
actualCmd := ""
if strings.Count(currCmd, "%x") == 1 {
actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536)
} else if strings.Count(currCmd, "%x") == 2 {
actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536)
} else if strings.Count(currCmd, "%x") == 3 {
actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536)
} else if strings.Count(currCmd, "%x") == 4 {
actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536)
} else if strings.Count(currCmd, "%x") == 5 {
actualCmd = fmt.Sprintf(currCmd, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536, rand.Int() % 65536)
} else {
actualCmd = currCmd
}
executeCmd(actualCmd)
}
}
func fileToCmd(filename string) []string {
fileBody, err := ioutil.ReadFile(filename)
if err != nil {
log.Printf("Error while reading file %s\n", filename)
return []string{}
}
cmdArr := strings.Split(string(fileBody), "\n")
return cmdArr
}
func executeCmd(cmdStr string) {
cmd := exec.Command("bash", "-c", cmdStr)
log.Println(cmdStr)
err := cmd.Run()
if err != nil {
log.Println(err)
}
}

BIN
sixes-to-fours

Binary file not shown.

8
up-six.sh.example

@ -0,0 +1,8 @@
# use configuration from hurricane electric to modify
# up to 5 hex placeholder in ipv6 allowed
ip tunnel add he-ipv6 mode sit remote 1.2.3.4 local 1.2.3.5 ttl 255
ip link set he-ipv6 up
ip addr add aaaa:aaa:aa:aaa::%x:%x/64 dev he-ipv6
ip route add ::/0 dev he-ipv6
ip -f inet6 addr
Loading…
Cancel
Save