Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
YouROK committed Aug 29, 2018
0 parents commit 0ca43a2
Show file tree
Hide file tree
Showing 54 changed files with 5,669 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

TorrServer.iml
.idea/

src/github.com/
src/golang.org/
src/bazil.org/
src/gopkg.in/
pkg/
bin/
dist/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## TorrServer
TorrServer, torrent to http

### Donate:
[PayPal](https://www.paypal.me/yourok)

[Yandex.Деньги](https://money.yandex.ru/to/410013733697114/100)

### Thanks to everyone who tested and helped

###### **kuzzman** [tv-box.pp.ua](http://tv-box.pp.ua/)

###### **MadAndron**

###### **SpAwN_LMG**

###### **Zivio**

###### **Tw1cker Руслан Пахнев** [github.com/Nemiroff](https://github.com/Nemiroff)
158 changes: 158 additions & 0 deletions build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#!/bin/bash
#
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
#
# To use:
#
# $ cd ~/path-to/my-awesome-project
# $ go-build-all
#
# Features:
#
# * Cross-compiles to multiple machine types and architectures.
# * Uses the current directory name as the output name...
# * ...unless you supply an source file: $ go-build-all main.go
# * Windows binaries are named .exe.
# * ARM v5, v6, v7 and v8 (arm64) support
#
# ARM Support:
#
# You must read https://github.com/golang/go/wiki/GoArm for the specifics of running
# Linux/BSD-style kernels and what kernel modules are needed for the target platform.
# While not needed for cross-compilation of this script, you're users will need to ensure
# the correct modules are included.
#
# Requirements:
#
# * GoLang 1.6+ (for mips and ppc), 1.5 for non-mips/ppc.
# * CD to directory of the binary you are compiling. $PWD is used here.
#
# For 1.4 and earlier, see http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
#

# This PLATFORMS list is refreshed after every major Go release.
# Though more platforms may be supported (freebsd/386), they have been removed
# from the standard ports/downloads and therefore removed from this list.
#
PLATFORMS=""
PLATFORMS="$PLATFORMS darwin/amd64" # amd64 only as of go1.5
PLATFORMS="$PLATFORMS windows/amd64 windows/386" # arm compilation not available for Windows
PLATFORMS="$PLATFORMS linux/amd64 linux/386"
# PLATFORMS="$PLATFORMS linux/ppc64 linux/ppc64le"
PLATFORMS="$PLATFORMS linux/mips linux/mipsle linux/mips64 linux/mips64le" # experimental in go1.6
#PLATFORMS="$PLATFORMS linux/arm linux/arm64"
# PLATFORMS="$PLATFORMS freebsd/amd64"
# PLATFORMS="$PLATFORMS netbsd/amd64" # amd64 only as of go1.6
# PLATFORMS="$PLATFORMS openbsd/amd64" # amd64 only as of go1.6
# PLATFORMS="$PLATFORMS dragonfly/amd64" # amd64 only as of go1.5
# PLATFORMS="$PLATFORMS plan9/amd64 plan9/386" # as of go1.4
# PLATFORMS="$PLATFORMS solaris/amd64" # as of go1.3

# ARMBUILDS lists the platforms that are currently supported. From this list
# we generate the following architectures:
#
# ARM64 (aka ARMv8) <- only supported on linux and darwin builds (go1.6)
# ARMv7
# ARMv6
# ARMv5
#
# Some words of caution from the master:
#
# @dfc: you'll have to use gomobile to build for darwin/arm64 [and others]
# @dfc: that target expects that you're bulding for a mobile phone
# @dfc: iphone 5 and below, ARMv7, iphone 3 and below ARMv6, iphone 5s and above arm64
#
# PLATFORMS_ARM="linux freebsd netbsd"
PLATFORMS_ARM="linux"

##############################################################
# Shouldn't really need to modify anything below this line. #
##############################################################

type setopt >/dev/null 2>&1

export GOPATH="${PWD}"

SCRIPT_NAME=`basename "$0"`
FAILURES=""
SOURCE_FILE="dist/TorrServer"
CURRENT_DIRECTORY=${PWD##*/}
OUTPUT=${SOURCE_FILE:-$CURRENT_DIRECTORY} # if no src file given, use current dir name

for PLATFORM in $PLATFORMS; do
GOOS=${PLATFORM%/*}
GOARCH=${PLATFORM#*/}
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
done

# ARM builds
if [[ $PLATFORMS_ARM == *"linux"* ]]; then
CMD="GOOS=linux GOARCH=arm64 go build -o ${OUTPUT}-linux-arm64 main"
echo "${CMD}"
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
fi

for GOOS in $PLATFORMS_ARM; do
GOARCH="arm"
# build for each ARM version
for GOARM in 7 6 5; do
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}${GOARM}"
CMD="GOARM=${GOARM} GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${BIN_FILENAME} main"
echo "${CMD}"
eval "${CMD}" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}"
done
done

# eval errors
if [[ "${FAILURES}" != "" ]]; then
echo ""
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
exit 1
fi

export CGO_ENABLED=1
export GOOS=android
export LDFLAGS="-s -w"

export NDK_TOOLCHAIN=/home/yourok/Space/Projects/GO/TorrServer/pkg/gomobile/ndk-toolchains/arm
export CC=$NDK_TOOLCHAIN/bin/arm-linux-androideabi-clang
export CXX=$NDK_TOOLCHAIN/bin/arm-linux-androideabi-clang++
export GOARCH=arm
export GOARM=7
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
echo "Android ${BIN_FILENAME}"
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main

export NDK_TOOLCHAIN=/home/yourok/Space/Projects/GO/TorrServer/pkg/gomobile/ndk-toolchains/arm64
export CC=$NDK_TOOLCHAIN/bin/aarch64-linux-android-clang
export CXX=$NDK_TOOLCHAIN/bin/aarch64-linux-android-clang++
export GOARCH=arm64
export GOARM=""
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
echo "Android ${BIN_FILENAME}"
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main

export NDK_TOOLCHAIN=/home/yourok/Space/Projects/GO/TorrServer/pkg/gomobile/ndk-toolchains/x86
export CC=$NDK_TOOLCHAIN/bin/i686-linux-android-clang
export CXX=$NDK_TOOLCHAIN/bin/i686-linux-android-clang++
export GOARCH=386
export GOARM=""
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
echo "Android ${BIN_FILENAME}"
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main

export NDK_TOOLCHAIN=/home/yourok/Space/Projects/GO/TorrServer/pkg/gomobile/ndk-toolchains/x86_64
export CC=$NDK_TOOLCHAIN/bin/x86_64-linux-android-clang
export CXX=$NDK_TOOLCHAIN/bin/x86_64-linux-android-clang++
export GOARCH=amd64
export GOARM=""
BIN_FILENAME="dist/TorrServer-${GOOS}-${GOARCH}${GOARM}"
echo "Android ${BIN_FILENAME}"
go build -ldflags="${LDFLAGS}" -o ${BIN_FILENAME} main

# ./compile.sh
7 changes: 7 additions & 0 deletions compile_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -x
export PATH=$PATH:/usr/local/go/bin/
export GOPATH=`pwd`
export ANDROID_HOME=$HOME'/Android/Sdk'
go get golang.org/x/mobile/cmd/gomobile
./bin/gomobile init -v -ndk /home/yourok/Android/Ndk/android-ndk/
84 changes: 84 additions & 0 deletions make.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package main

import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
"time"
)

func main() {
if len(os.Args) < 2 {
fmt.Println("Need version")
os.Exit(1)
}
release_version := os.Args[1]
isTest := false
if len(os.Args) > 2 {
isTest = true
}

fmt.Println("\nMake:", release_version, "\n")
cmd := exec.Command("./build-all.sh")
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
fmt.Println("Error compile", err)
os.Exit(1)
}
files, err := ioutil.ReadDir("dist")
if err != nil {
fmt.Println("Error read dist")
os.Exit(1)
}

fmt.Println("\nMake json")
js := Release{}
js.Name = "TorrServer"
js.Version = release_version
js.BuildDate = time.Now().Format("02.01.2006")
js.Links = make(map[string]string)
for _, f := range files {
arch := strings.TrimPrefix(f.Name(), "TorrServer-")
js.Links[arch] = "https://github.com/YouROK/TorrServer/releases/download/" + release_version + "/" + f.Name()
}
buf, err := json.MarshalIndent(&js, "", " ")
if err != nil {
fmt.Println("Error make json")
os.Exit(1)
}
if isTest {
err = ioutil.WriteFile("test.json", buf, 0666)
} else {
err = ioutil.WriteFile("release.json", buf, 0666)
}
if err != nil {
fmt.Println("Error write to json file:", err)
os.Exit(1)
}
fmt.Println("\n\nEnter tag manually:\n")
fmt.Println("git push origin", release_version)
fmt.Println()
}

type Release struct {
Name string
Version string
BuildDate string
Links map[string]string
}

//"update": {
//"name": "TorrServer",
//"version": "1.0.61",
//"build_date": "20.07.2018",
//"links":[
//{"android-386":"https://github.com/YouROK/TorrServe/releases/download/1.0.61/TorrServer-android-386"},
//{"android-amd64":"https://github.com/YouROK/TorrServe/releases/download/1.0.61/TorrServer-android-amd64"},
//{"android-arm7":"https://github.com/YouROK/TorrServe/releases/download/1.0.61/TorrServer-android-arm7"},
//{"android-arm64":"https://github.com/YouROK/TorrServe/releases/download/1.0.61/TorrServer-android-arm64"},
//]
//}
3 changes: 3 additions & 0 deletions make_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

go run make.go $@
24 changes: 24 additions & 0 deletions release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"Name": "TorrServer",
"Version": "1.1.65",
"BuildDate": "29.08.2018",
"Links": {
"android-386": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-android-386",
"android-amd64": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-android-amd64",
"android-arm64": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-android-arm64",
"android-arm7": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-android-arm7",
"darwin-amd64": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-darwin-amd64",
"linux-386": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-386",
"linux-amd64": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-amd64",
"linux-arm5": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-arm5",
"linux-arm6": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-arm6",
"linux-arm64": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-arm64",
"linux-arm7": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-arm7",
"linux-mips": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-mips",
"linux-mips64": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-mips64",
"linux-mips64le": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-mips64le",
"linux-mipsle": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-linux-mipsle",
"windows-386.exe": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-windows-386.exe",
"windows-amd64.exe": "https://github.com/YouROK/TorrServer/releases/download/1.1.65/TorrServer-windows-amd64.exe"
}
}
Loading

0 comments on commit 0ca43a2

Please sign in to comment.