Skip to content

Commit

Permalink
Merge pull request #1 from eyedeekay/pages
Browse files Browse the repository at this point in the history
Pages
  • Loading branch information
eyedeekay committed Oct 15, 2019
2 parents 9ba5790 + 1f8f1bd commit a8ca50b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 25 additions & 3 deletions gitsam.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
Binary file modified gitsam/gitsam
Binary file not shown.
8 changes: 4 additions & 4 deletions gitsam/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export SCRIPTDIR=$(dirname $(readlink -f "$0"))
. $SCRIPTDIR/.config
export CONTENT=$SCRIPTDIR/$UN

cd "$CONTENT" && $SCRIPTDIR/gitsam/gitsam
cd "$CONTENT" && $SCRIPTDIR/gitsam/gitsam -il 1 -ol 1 -iq 8 -oq 8 -ib 3 -ob 3 -pk ../.gitsam_secure/id_rsa.pub
17 changes: 10 additions & 7 deletions site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a8ca50b

Please sign in to comment.