|
|
@ -1,6 +1,7 @@ |
|
|
|
package main |
|
|
|
package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
_ "embed" |
|
|
|
"flag" |
|
|
|
"flag" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"os" |
|
|
|
"os" |
|
|
@ -11,15 +12,26 @@ import ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// flags
|
|
|
|
// flags
|
|
|
|
var PORT *int = flag.Int("port", 8080, "Specifies a port for a sender|port to connect to") |
|
|
|
var ( |
|
|
|
var SENDERADDR *string = flag.String("addr", "", "Specifies an address to connect to") |
|
|
|
PORT *int = flag.Int("port", 8080, "Specifies a port for a sender|port to connect to") |
|
|
|
var DOWNLOADSFOLDER *string = flag.String("downloadto", ".", "Specifies where the receiver will store downloaded file") |
|
|
|
SENDERADDR *string = flag.String("addr", "", "Specifies an address to connect to") |
|
|
|
var SHAREDFILE *string = flag.String("sharefile", "", "Specifies what file sender will send") |
|
|
|
DOWNLOADSFOLDER *string = flag.String("downloadto", ".", "Specifies where the receiver will store downloaded file") |
|
|
|
|
|
|
|
SHAREDFILE *string = flag.String("sharefile", "", "Specifies what file sender will send") |
|
|
|
|
|
|
|
LICENSE *bool = flag.Bool("license", false, "Prints a license text") |
|
|
|
|
|
|
|
|
|
|
|
var SENDING bool |
|
|
|
SENDING bool |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//go:embed LICENSE
|
|
|
|
|
|
|
|
LicenseText string |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// Input-validation
|
|
|
|
// Input-validation
|
|
|
|
func validateFlags() { |
|
|
|
func validateFlags() { |
|
|
|
|
|
|
|
if *LICENSE { |
|
|
|
|
|
|
|
fmt.Println(LicenseText) |
|
|
|
|
|
|
|
os.Exit(0) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// port validation
|
|
|
|
// port validation
|
|
|
|
if *PORT < 0 { |
|
|
|
if *PORT < 0 { |
|
|
|
fmt.Println("Invalid port !") |
|
|
|
fmt.Println("Invalid port !") |
|
|
|