Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b2c6f313bc | |||
| b9f4c25f39 | |||
| 531abdafde | |||
| 9f0d81e7f1 | |||
| ed9d45d343 | |||
| a7b0a5d113 | |||
| 91be76b82e | |||
| 95c4a1738b | |||
| 607466dd65 | |||
| e3e80d450b | |||
| e995d436c2 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.DS_Store
|
||||||
|
dist/
|
||||||
|
release/
|
||||||
50
.goreleaser.yaml
Normal file
50
.goreleaser.yaml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
- go mod tidy
|
||||||
|
- go test ./...
|
||||||
|
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- windows
|
||||||
|
- darwin
|
||||||
|
- freebsd
|
||||||
|
goarch:
|
||||||
|
- arm
|
||||||
|
- arm64
|
||||||
|
- amd64
|
||||||
|
goarm:
|
||||||
|
- 6
|
||||||
|
- 7
|
||||||
|
ignore:
|
||||||
|
- goos: darwin
|
||||||
|
goarch: arm
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm64
|
||||||
|
- goos: freebsd
|
||||||
|
goarch: arm
|
||||||
|
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- formats: [tar.gz]
|
||||||
|
# this name template makes the OS and Arch compatible with the results of `uname`.
|
||||||
|
name_template: >-
|
||||||
|
{{ .ProjectName }}_
|
||||||
|
{{- title .Os }}_
|
||||||
|
{{- if eq .Arch "amd64" }}x86_64
|
||||||
|
{{- else if eq .Arch "386" }}i386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||||
|
# use zip for windows archives
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
formats: [zip]
|
||||||
|
|
||||||
|
changelog:
|
||||||
|
disable: true
|
||||||
13
.vscode/settings.json
vendored
13
.vscode/settings.json
vendored
@@ -1,9 +1,20 @@
|
|||||||
{
|
{
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"authtoken",
|
||||||
"Debugf",
|
"Debugf",
|
||||||
"Infof",
|
"Infof",
|
||||||
"isatty",
|
"isatty",
|
||||||
"netgiv",
|
"netgiv",
|
||||||
"pflag"
|
"ngfs",
|
||||||
|
"tardisx",
|
||||||
|
"ttys"
|
||||||
|
],
|
||||||
|
"cSpell.ignoreWords": [
|
||||||
|
"logrus",
|
||||||
|
"mattn",
|
||||||
|
"pflag",
|
||||||
|
"sigchan",
|
||||||
|
"sirupsen",
|
||||||
|
"verysecretvaluehere"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ and place the binary somewhere on your $PATH.
|
|||||||
|
|
||||||
Copy and paste for the trusting & lazy:
|
Copy and paste for the trusting & lazy:
|
||||||
|
|
||||||
curl -L https://github.com/tardisx/netgiv/releases/download/v0.0.3/netgiv-linux-v0.0.3.zip | funzip > netgiv && chmod a+x netgiv
|
curl -L https://github.com/tardisx/netgiv/releases/download/v0.0.4/netgiv-linux-v0.0.4.zip | funzip > netgiv && chmod a+x netgiv
|
||||||
|
|
||||||
### Compiling from source
|
### Compiling from source
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
#!/usr/bin/env perl
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
open my $fh, "<", "main.go" || die $!;
|
|
||||||
|
|
||||||
my $version;
|
|
||||||
while (<$fh>) {
|
|
||||||
# CurrentVersion: "v0.04"
|
|
||||||
$version = $1 if /CurrentVersion\s*=\s*"(v[\d\.]+)"/;
|
|
||||||
}
|
|
||||||
close $fh;
|
|
||||||
|
|
||||||
die "no version?" unless defined $version;
|
|
||||||
|
|
||||||
# quit if tests fail
|
|
||||||
system("go test ./...") && die "not building release with failing tests";
|
|
||||||
|
|
||||||
# so lazy
|
|
||||||
system "rm", "-rf", "release", "dist";
|
|
||||||
system "mkdir", "release";
|
|
||||||
system "mkdir", "dist";
|
|
||||||
|
|
||||||
my %build = (
|
|
||||||
win => { env => { GOOS => 'windows', GOARCH => 'amd64' }, filename => 'netgiv.exe' },
|
|
||||||
linux => { env => { GOOS => 'linux', GOARCH => 'amd64' }, filename => 'netgiv' },
|
|
||||||
mac => { env => { GOOS => 'darwin', GOARCH => 'amd64' }, filename => 'netgiv' },
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach my $type (keys %build) {
|
|
||||||
mkdir "release/$type";
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $type (keys %build) {
|
|
||||||
local $ENV{GOOS} = $build{$type}->{env}->{GOOS};
|
|
||||||
local $ENV{GOARCH} = $build{$type}->{env}->{GOARCH};
|
|
||||||
system "go", "build", "-o", "release/$type/" . $build{$type}->{filename};
|
|
||||||
system "zip", "-j", "dist/netgiv-$type-$version.zip", ( glob "release/$type/*" );
|
|
||||||
}
|
|
||||||
26
main.go
26
main.go
@@ -13,8 +13,6 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var CurrentVersion = "v0.0.4"
|
|
||||||
|
|
||||||
const ProtocolVersion = "1.1"
|
const ProtocolVersion = "1.1"
|
||||||
|
|
||||||
type PasteValue struct {
|
type PasteValue struct {
|
||||||
@@ -71,6 +69,12 @@ func getAuthTokenFromTerminal() string {
|
|||||||
return pass
|
return pass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
version = "dev"
|
||||||
|
commit = "none"
|
||||||
|
date = "unknown"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
isServer := flag.Bool("server", false, "Run netgiv in server mode")
|
isServer := flag.Bool("server", false, "Run netgiv in server mode")
|
||||||
|
|
||||||
@@ -91,8 +95,15 @@ func main() {
|
|||||||
flag.String("authtoken", "", "Authentication token")
|
flag.String("authtoken", "", "Authentication token")
|
||||||
flag.Int("port", 0, "Port")
|
flag.Int("port", 0, "Port")
|
||||||
|
|
||||||
|
versionFlag := flag.BoolP("version", "v", false, "show version and exit")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if versionFlag != nil && *versionFlag {
|
||||||
|
fmt.Print(versionInfo(true))
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
receiveNum := int(pasteFlag.PasteNumber)
|
receiveNum := int(pasteFlag.PasteNumber)
|
||||||
if !pasteFlag.PasteRequired {
|
if !pasteFlag.PasteRequired {
|
||||||
receiveNum = -1
|
receiveNum = -1
|
||||||
@@ -112,7 +123,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.Parse()
|
|
||||||
viper.BindPFlags(flag.CommandLine)
|
viper.BindPFlags(flag.CommandLine)
|
||||||
|
|
||||||
viper.SetEnvPrefix("NETGIV")
|
viper.SetEnvPrefix("NETGIV")
|
||||||
@@ -200,3 +210,13 @@ environment variable. This may be preferable in some environments.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func versionInfo(verbose bool) string {
|
||||||
|
out := ""
|
||||||
|
out += fmt.Sprintf("netgiv %s, built at %s\n", version, date)
|
||||||
|
if verbose {
|
||||||
|
out += fmt.Sprintf("commit: %s\n", commit)
|
||||||
|
out += fmt.Sprintf("http://github.com/tardisx/netgiv\n")
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,10 +34,15 @@ type NGF struct {
|
|||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ngf NGF) String() string {
|
||||||
|
return fmt.Sprintf("id: %d, stored: %s, size: %d, kind: %s", ngf.Id, ngf.StorePath, ngf.Size, ngf.Kind)
|
||||||
|
}
|
||||||
|
|
||||||
var ngfs []NGF
|
var ngfs []NGF
|
||||||
var globalId uint32
|
var globalId uint32
|
||||||
|
|
||||||
func (s *Server) Run() {
|
func (s *Server) Run() {
|
||||||
|
log.Info(versionInfo(false))
|
||||||
log.Infof("starting server on :%d", s.port)
|
log.Infof("starting server on :%d", s.port)
|
||||||
address := fmt.Sprintf(":%d", s.port)
|
address := fmt.Sprintf(":%d", s.port)
|
||||||
networkAddress, _ := net.ResolveTCPAddr("tcp", address)
|
networkAddress, _ := net.ResolveTCPAddr("tcp", address)
|
||||||
|
|||||||
Reference in New Issue
Block a user