Merge branch 'master' of github.com:schollz/croc

This commit is contained in:
Zack Scholl 2021-02-03 10:08:40 -08:00
commit 77fd78e408
6 changed files with 14 additions and 17 deletions

View File

@ -2,7 +2,7 @@ FROM golang:1.15-alpine as builder
RUN apk add --no-cache git RUN apk add --no-cache git
WORKDIR /go/croc WORKDIR /go/croc
COPY . . COPY . .
RUN go build -v RUN go build -v -ldflags="-s -w"
FROM alpine:latest FROM alpine:latest
EXPOSE 9009 EXPOSE 9009

View File

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2017-2020 Zack Copyright (c) 2017-2021 Zack
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -77,12 +77,6 @@ On Arch Linux you can install the latest release with `pacman`:
$ pacman -S croc $ pacman -S croc
``` ```
On Ubuntu you can install with `snap`:
```
$ snap install croc
```
On Gentoo you can install with `portage`: On Gentoo you can install with `portage`:
``` ```
$ emerge net-misc/croc $ emerge net-misc/croc

View File

@ -5,7 +5,7 @@ package main
//go:generate git tag -af v$VERSION -m "v$VERSION" //go:generate git tag -af v$VERSION -m "v$VERSION"
import ( import (
"fmt" "log"
"github.com/schollz/croc/v8/src/cli" "github.com/schollz/croc/v8/src/cli"
) )
@ -28,6 +28,6 @@ func main() {
// } // }
// }() // }()
if err := cli.Run(); err != nil { if err := cli.Run(); err != nil {
fmt.Println(err) log.Fatalln(err)
} }
} }

View File

@ -85,6 +85,7 @@ func Run() (err error) {
&cli.BoolFlag{Name: "no-compress", Usage: "disable compression"}, &cli.BoolFlag{Name: "no-compress", Usage: "disable compression"},
&cli.BoolFlag{Name: "ask", Usage: "make sure sender and recipient are prompted"}, &cli.BoolFlag{Name: "ask", Usage: "make sure sender and recipient are prompted"},
&cli.BoolFlag{Name: "local", Usage: "force to use only local connections"}, &cli.BoolFlag{Name: "local", Usage: "force to use only local connections"},
&cli.BoolFlag{Name: "ignore-stdin", Usage: "ignore piped stdin"},
&cli.StringFlag{Name: "ip", Value: "", Usage: "set sender ip if known e.g. 10.0.0.1:9009, [::1]:9009"}, &cli.StringFlag{Name: "ip", Value: "", Usage: "set sender ip if known e.g. 10.0.0.1:9009, [::1]:9009"},
&cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay", EnvVars: []string{"CROC_RELAY"}}, &cli.StringFlag{Name: "relay", Value: models.DEFAULT_RELAY, Usage: "address of the relay", EnvVars: []string{"CROC_RELAY"}},
&cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay", EnvVars: []string{"CROC_RELAY6"}}, &cli.StringFlag{Name: "relay6", Value: models.DEFAULT_RELAY6, Usage: "ipv6 address of the relay", EnvVars: []string{"CROC_RELAY6"}},
@ -177,6 +178,7 @@ func send(c *cli.Context) (err error) {
Stdout: c.Bool("stdout"), Stdout: c.Bool("stdout"),
DisableLocal: c.Bool("no-local"), DisableLocal: c.Bool("no-local"),
OnlyLocal: c.Bool("local"), OnlyLocal: c.Bool("local"),
IgnoreStdin: c.Bool("ignore-stdin"),
RelayPorts: strings.Split(c.String("ports"), ","), RelayPorts: strings.Split(c.String("ports"), ","),
Ask: c.Bool("ask"), Ask: c.Bool("ask"),
NoMultiplexing: c.Bool("no-multi"), NoMultiplexing: c.Bool("no-multi"),
@ -217,15 +219,15 @@ func send(c *cli.Context) (err error) {
var fnames []string var fnames []string
stat, _ := os.Stdin.Stat() stat, _ := os.Stdin.Stat()
if (stat.Mode() & os.ModeCharDevice) == 0 { if ((stat.Mode() & os.ModeCharDevice) == 0) && !c.Bool("ignore-stdin") {
fnames, err = getStdin() fnames, err = getStdin()
if err != nil { if err != nil {
return return
} }
defer func() { defer func() {
err = os.Remove(fnames[0]) e := os.Remove(fnames[0])
if err != nil { if e != nil {
log.Error(err) log.Error(e)
} }
}() }()
} else if c.String("text") != "" { } else if c.String("text") != "" {
@ -234,9 +236,9 @@ func send(c *cli.Context) (err error) {
return return
} }
defer func() { defer func() {
err = os.Remove(fnames[0]) e := os.Remove(fnames[0])
if err != nil { if e != nil {
log.Error(err) log.Error(e)
} }
}() }()

View File

@ -61,6 +61,7 @@ type Options struct {
NoMultiplexing bool NoMultiplexing bool
DisableLocal bool DisableLocal bool
OnlyLocal bool OnlyLocal bool
IgnoreStdin bool
Ask bool Ask bool
SendingText bool SendingText bool
NoCompress bool NoCompress bool