11 Commits

Author SHA1 Message Date
b2c6f313bc Spelling 2025-04-25 13:23:21 +09:30
b9f4c25f39 Spelling 2025-04-25 13:21:24 +09:30
531abdafde Show version info in server log 2025-04-25 13:20:43 +09:30
9f0d81e7f1 Remove unused version var 2025-04-25 13:20:29 +09:30
ed9d45d343 Improve output in log 2025-04-25 13:16:11 +09:30
a7b0a5d113 Show version, embedded by goreleaser 2025-04-25 13:15:57 +09:30
91be76b82e Spelling 2025-04-25 13:15:43 +09:30
95c4a1738b More archs 2025-04-25 13:01:33 +09:30
607466dd65 Brave new world of releasing 2025-04-25 12:48:08 +09:30
e3e80d450b Add .gitignore 2022-01-26 11:33:55 +10:30
e995d436c2 Update instructions 2022-01-26 10:57:12 +10:30
7 changed files with 94 additions and 45 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.DS_Store
dist/
release/

50
.goreleaser.yaml Normal file
View 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
View File

@@ -1,9 +1,20 @@
{
"cSpell.words": [
"authtoken",
"Debugf",
"Infof",
"isatty",
"netgiv",
"pflag"
"ngfs",
"tardisx",
"ttys"
],
"cSpell.ignoreWords": [
"logrus",
"mattn",
"pflag",
"sigchan",
"sirupsen",
"verysecretvaluehere"
]
}

View File

@@ -31,7 +31,7 @@ and place the binary somewhere on your $PATH.
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

View File

@@ -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
View File

@@ -13,8 +13,6 @@ import (
"github.com/spf13/viper"
)
var CurrentVersion = "v0.0.4"
const ProtocolVersion = "1.1"
type PasteValue struct {
@@ -71,6 +69,12 @@ func getAuthTokenFromTerminal() string {
return pass
}
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
isServer := flag.Bool("server", false, "Run netgiv in server mode")
@@ -91,8 +95,15 @@ func main() {
flag.String("authtoken", "", "Authentication token")
flag.Int("port", 0, "Port")
versionFlag := flag.BoolP("version", "v", false, "show version and exit")
flag.Parse()
if versionFlag != nil && *versionFlag {
fmt.Print(versionInfo(true))
os.Exit(0)
}
receiveNum := int(pasteFlag.PasteNumber)
if !pasteFlag.PasteRequired {
receiveNum = -1
@@ -112,7 +123,6 @@ func main() {
}
}
flag.Parse()
viper.BindPFlags(flag.CommandLine)
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
}

View File

@@ -34,10 +34,15 @@ type NGF struct {
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 globalId uint32
func (s *Server) Run() {
log.Info(versionInfo(false))
log.Infof("starting server on :%d", s.port)
address := fmt.Sprintf(":%d", s.port)
networkAddress, _ := net.ResolveTCPAddr("tcp", address)