aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2021-07-28 23:05:49 +0300
committeraqua <aqua@iserlohn-fortress.net>2021-07-28 23:05:49 +0300
commitd5e25d80182d38b49f6e4a78bed653e4bdb9c747 (patch)
tree4d65849f203523f43f1ba21838161bf56d589344
parentInitial commit (diff)
downloadgemcat-d5e25d80182d38b49f6e4a78bed653e4bdb9c747.tar.xz
Use cmd args to get request url
-rw-r--r--main.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/main.go b/main.go
index cf5b69e..cae68ab 100644
--- a/main.go
+++ b/main.go
@@ -2,17 +2,41 @@ package main
import (
"crypto/tls"
+ "flag"
+ "fmt"
"log"
+ "os"
+ "strconv"
)
-const url = "gemini.circumlunar.space:1965"
-const request = "gemini://gemini.circumlunar.space/\r\n"
+var port = 1965
+
+func usage() {
+ fmt.Printf("Usage: %s [options] url\n", os.Args[0])
+ flag.PrintDefaults()
+}
func main() {
+ flag.Usage = usage
+
+ flag.IntVar(&port, "p", port, "server port number")
+
+ flag.Parse()
+ if flag.NArg() != 1 {
+ fmt.Printf("Got %d arguments, expected 1\n", flag.NArg())
+ flag.Usage()
+ os.Exit(1)
+ }
+
+ url := flag.Arg(0) + ":" + strconv.Itoa(port)
+ request := "gemini://" + flag.Arg(0) + "/\r\n"
+
conf := tls.Config{
InsecureSkipVerify: true,
}
+ log.Println("connecting to: " + url)
+
conn, err := tls.Dial("tcp", url, &conf)
if err != nil {