diff --git a/.gitignore b/.gitignore index 304e34a..f1c181e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,3 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out -./id_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pubid_rsa.pub \ No newline at end of file diff --git a/Makefile b/Makefile index 43873f7..83d9a08 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,14 @@ fmt: USER_GH=eyedeekay packagename=gitsam -VERSION=0.0.992 +VERSION=0.0.994 tag: gothub release -s $(GITHUB_TOKEN) -u $(USER_GH) -r $(packagename) -t v$(VERSION) -d "I2P Tunnel Management tool for Go applications" mod: go get -u github.com/$(USER_GH)/$(packagename)@v$(VERSION) + +serve: + docker build -t eyedeekay/gitsam -f Dockerfile . + #docker run -itd --restart=always \ No newline at end of file diff --git a/gitsam.go b/gitsam.go index d8d27fd..81ad6af 100644 --- a/gitsam.go +++ b/gitsam.go @@ -38,7 +38,10 @@ var err error func (s *GitSAMTunnel) PRBytes() []byte { r := "#!/bin/sh" - r += "GIT_WORK_TREE=" + s.GitConf.Dir + " git checkout -f\n" + r += "GIT_WORK_TREE=" + s.GitConf.Dir + " git checkout -f master\n" + r += "GIT_WORK_TREE=" + s.GitConf.Dir + " git branch -D pages\n" + r += "GIT_WORK_TREE=" + s.GitConf.Dir + " git checkout -f pages\n" + r += "GIT_WORK_TREE=" + s.GitConf.Dir + " git merge origin/master\n" return []byte(r) } @@ -99,7 +102,14 @@ func (s *GitSAMTunnel) AssurePostRecieve() error { dirpath = s.GitConf.Dir } - cmd := exec.Command("git", "update-server-info") + cmd := exec.Command("git", "checkout", "-b", "pages") + cmd.Dir = dirpath + cmd.Env = []string{"GIT_WORK_TREE=" + dirpath} + if err := cmd.Run(); err != nil { + log.Println(err) + } + log.Println("checked out page branch for static copy", cmd.Dir) + cmd = exec.Command("git", "update-server-info") cmd.Dir = dirpath cmd.Env = []string{"GIT_WORK_TREE=" + dirpath} if err := cmd.Run(); err != nil { @@ -187,7 +197,7 @@ func (s *GitSAMTunnel) AssureGitIgnore() error { return err } } else { - if err := ioutil.WriteFile(filepath.Join(s.GitConf.Dir, "/.gitignore"), []byte(PubKeyPath), 0644); err != nil { + if err := ioutil.WriteFile(filepath.Join(s.GitConf.Dir, "/.gitignore"), []byte(PubKeyPath+"\n"), 0644); err != nil { return err } } @@ -197,6 +207,16 @@ func (s *GitSAMTunnel) AssureGitIgnore() error { func (f *GitSAMTunnel) LookupKey(content string) (*gitkit.PublicKey, error) { textkey, err := ioutil.ReadFile(f.PubKeyPath) + log.Println("This is the content\n", content, "\n", string(textkey)) + if !strings.HasPrefix(string(textkey), content) { + log.Println( + "\nContent:", + content, + "\nTextKey:", + string(textkey), + ) + return nil, nil + } if err != nil { return nil, err } @@ -306,11 +326,13 @@ func NewGitSAMTunnelFromOptions(opts ...func(*GitSAMTunnel) error) (*GitSAMTunne s.SAMForwarder.Config().SaveDirectory = s.SecurePath s.SAMForwarder.Config().FilePath = s.SecurePath } + s.GitConf.Auth = true conf := *s.Conf conf.CloseIdleTime = 6000000 conf.TargetPort = s.PagePort conf.TunName = s.ID() + "-eephttpd" conf.SaveDirectory = s.Conf.SaveDirectory + conf.Type = "server" log.Println("Setting up secure path", s.Conf.SaveDirectory, conf.SaveDirectory) if s.OptPage, err = i2ptunhelper.NewEepHttpdFromConf(&conf); err != nil { return nil, err diff --git a/gitsam/gitsam b/gitsam/gitsam index 8bce06d..d94c3dc 100755 Binary files a/gitsam/gitsam and b/gitsam/gitsam differ diff --git a/gitsam/main.go b/gitsam/main.go index 4ef2377..825f54b 100644 --- a/gitsam/main.go +++ b/gitsam/main.go @@ -42,12 +42,12 @@ var ( reduceIdleQuantity = flag.Int("rc", 3, "Reduce idle tunnel quantity to X (0 to 5)") inLength = flag.Int("il", 3, "Set inbound tunnel length(0 to 7)") outLength = flag.Int("ol", 3, "Set outbound tunnel length(0 to 7)") - inQuantity = flag.Int("iq", 2, "Set inbound tunnel quantity(0 to 15)") - outQuantity = flag.Int("oq", 2, "Set outbound tunnel quantity(0 to 15)") + inQuantity = flag.Int("iq", 3, "Set inbound tunnel quantity(0 to 15)") + outQuantity = flag.Int("oq", 3, "Set outbound tunnel quantity(0 to 15)") inVariance = flag.Int("iv", 0, "Set inbound tunnel length variance(-7 to 7)") outVariance = flag.Int("ov", 0, "Set outbound tunnel length variance(-7 to 7)") - inBackupQuantity = flag.Int("ib", 1, "Set inbound tunnel backup quantity(0 to 5)") - outBackupQuantity = flag.Int("ob", 1, "Set outbound tunnel backup quantity(0 to 5)") + inBackupQuantity = flag.Int("ib", 3, "Set inbound tunnel backup quantity(0 to 5)") + outBackupQuantity = flag.Int("ob", 3, "Set outbound tunnel backup quantity(0 to 5)") iniFile = flag.String("f", "none", "Use an ini file for configuration") authkeys = flag.String("pk", "./id_rsa.pub", "Path to the authorized users SSH public key") servkeys = flag.String("sk", "", "Path to the directory with the private keys used to authenticate the server") diff --git a/run.sh b/run.sh index 68c93bb..6a573aa 100755 --- a/run.sh +++ b/run.sh @@ -5,4 +5,4 @@ export SCRIPTDIR=$(dirname $(readlink -f "$0")) . $SCRIPTDIR/.config export CONTENT=$SCRIPTDIR/$UN -cd "$CONTENT" && $SCRIPTDIR/gitsam/gitsam \ No newline at end of file +cd "$CONTENT" && $SCRIPTDIR/gitsam/gitsam -il 1 -ol 1 -iq 8 -oq 8 -ib 3 -ob 3 -pk ../.gitsam_secure/id_rsa.pub \ No newline at end of file diff --git a/site.sh b/site.sh index 77d2cc1..51fd127 100755 --- a/site.sh +++ b/site.sh @@ -16,17 +16,20 @@ $GH$UN/sam3 $GH$UN/outproxy" mkdir -p "$CONTENT" $SCRIPTDIR/.gitsam_secure -cd "$CONTENT" +cd "$CONTENT" && pwd for x in $GIT_REPOS; do THEDIR=$CONTENT/$(echo "$x" | sed "s|$GH$UN/||g") - mkdir -p $(echo "$x" | sed "s|$GH$UN/||g") - git clone "$x" $THEDIR/ 2>&1 | grep -v fatal + echo $THEDIR + mkdir -p $THEDIR + git clone --mirror "$x" 2>&1 | grep -v fatal cd $THEDIR - pwd - git pull --force --all --keep --update-head-ok --progress + pwd && ls "$THEDIR/.git" + git init + git checkout -f + git checkout -b pages + git fetch --force --all --keep --progress --update-head-ok --tags git update-server-info -f && echo "updated server info" + git fsck cd "$CONTENT" done - -$SCRIPTDIR/run.sh