-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4337184
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# A simple file share program | ||
|
||
Just like `python -m SimpleHTTPServer`, it opens a simple web server, you can get files from another computer of a phone. | ||
|
||
|
||
``` | ||
$ ./fileshare.exe | ||
Open your browser to the address below: | ||
http://192.168.200.124:8080 | ||
...QRCODE HERE... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"github.com/Baozisoftware/qrcode-terminal-go" | ||
"log" | ||
"net" | ||
"net/http" | ||
) | ||
|
||
func main() { | ||
port := flag.Int("port", 8080, "port number") | ||
|
||
flag.Parse() | ||
|
||
addrs, err := net.InterfaceAddrs() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
obj := qrcodeTerminal.New2(qrcodeTerminal.ConsoleColors.BrightBlue, qrcodeTerminal.ConsoleColors.BrightGreen, qrcodeTerminal.QRCodeRecoveryLevels.Medium) | ||
fmt.Println("Open your browser to the address below, or you can scan the qrcode from your phone.") | ||
for _, addr := range addrs { | ||
if ipnet, ok := addr.(*net.IPNet); ok && ipnet.IP.IsGlobalUnicast() && ipnet.IP.To4() != nil { | ||
url := fmt.Sprintf("http://%s:%d", ipnet.IP.String(), *port) | ||
fmt.Println(url) | ||
|
||
obj.Get([]byte(url)).Print() | ||
fmt.Println() | ||
} | ||
} | ||
|
||
http.Handle("/", http.FileServer(http.Dir("."))) | ||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) | ||
} |