Skip to content

Commit

Permalink
Add qr code support
Browse files Browse the repository at this point in the history
  • Loading branch information
chyok committed Nov 24, 2023
1 parent b418c05 commit a9b868a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.21.1

require (
github.com/schollz/progressbar/v3 v3.14.1
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/urfave/cli/v2 v2.25.7
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/schollz/progressbar/v3 v3.14.1 h1:VD+MJPCr4s3wdhTc7OEJ/Z3dAeBzJ7yKH/P4lC5yRTI=
github.com/schollz/progressbar/v3 v3.14.1/go.mod h1:Zc9xXneTzWXF81TGoqL71u0sBPjULtEHYtj/WVgVy8E=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/chyok/st/internal/pkg/discovery"
"github.com/chyok/st/internal/pkg/transfer"
"github.com/chyok/st/template"
"github.com/skip2/go-qrcode"

"github.com/urfave/cli/v2"
)
Expand All @@ -24,7 +25,10 @@ func sendFile(c *cli.Context) error {
}

func receiveFile(c *cli.Context) error {
fmt.Println("server address: http://" + config.G.LocalIP + ":" + config.G.Port)
address := fmt.Sprintf("http://%s:%s", config.G.LocalIP, config.G.Port)
q, _ := qrcode.New(address, qrcode.Low)
fmt.Println(q.ToSmallString(false))
fmt.Printf("Server address: %s \n", address)
fmt.Println("Waiting transfer...")
go discovery.Listen(config.G.MulticastAddress)
http.HandleFunc("/", transfer.ReceiveFileHandler)
Expand Down

0 comments on commit a9b868a

Please sign in to comment.