mirror of
https://github.com/openziti/zrok.git
synced 2025-01-22 13:58:49 +01:00
use os.Stdin to read the pastebin text (#379)
This commit is contained in:
parent
6eddcedb32
commit
33a8088377
@ -4,13 +4,24 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openziti/zrok/environment"
|
"github.com/openziti/zrok/environment"
|
||||||
"github.com/openziti/zrok/sdk"
|
"github.com/openziti/zrok/sdk"
|
||||||
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const MAX_PASTE_SIZE = 64 * 1024
|
||||||
|
|
||||||
|
var data []byte
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var err error
|
||||||
|
data, err = io.ReadAll(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
root, err := environment.LoadRoot()
|
root, err := environment.LoadRoot()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -53,7 +64,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handle(conn net.Conn) {
|
func handle(conn net.Conn) {
|
||||||
_, err := conn.Write([]byte("hello from pastebin"))
|
_, err := conn.Write(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error: %v\n", err)
|
fmt.Printf("error: %v\n", err)
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const MAX_PASTE_SIZE = 64 * 1024
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) < 2 {
|
if len(os.Args) < 2 {
|
||||||
panic("usage: pastefrom <shrToken>")
|
panic("usage: pastefrom <shrToken>")
|
||||||
@ -36,7 +38,7 @@ func main() {
|
|||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
buf := make([]byte, 10240)
|
buf := make([]byte, MAX_PASTE_SIZE)
|
||||||
n, err := conn.Read(buf)
|
n, err := conn.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user