projects
/
k_transpose.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
08ff4e7
)
begin url host swap code
author
kremlin
<ian@kremlin.cc>
Sat, 24 Jan 2015 15:48:03 +0000
(10:48 -0500)
committer
kremlin
<ian@kremlin.cc>
Sat, 24 Jan 2015 15:48:03 +0000
(10:48 -0500)
httpd.go
patch
|
blob
|
blame
|
history
diff --git
a/httpd.go
b/httpd.go
index d50afdcd50f23770a924dc834dba48b70ca94a18..d90450e10578d57d163e1024329fb11b9b11655e 100644
(file)
--- a/
httpd.go
+++ b/
httpd.go
@@
-4,9
+4,13
@@
import(
"fmt"
"os"
"fmt"
"os"
+ "io"
+// "io/ioutil"
+ "bufio"
+
"strings"
"strconv"
"strings"
"strconv"
- "
bufio
"
+ "
text/scanner
"
"net/http"
"net/http"
@@
-189,19
+193,50
@@
func ktInit(dirPrepend string, port int, colorfilePath string) error {
if pal == ansiColors {}
if pal == ansiColors {}
+ color.Printf("@yverifying & preprocessing colorsets@{|} :: @y[SKIP]\n")
+ color.Printf("@ygenerating transpositional colorspace@{|} :: @y[SKIP]\n")
+
color.Printf("@ystarting httpd on port @b%d@{|} :: ", port)
color.Printf("@ystarting httpd on port @b%d@{|} :: ", port)
+ http.HandleFunc("/kt/", transposePage)
+ var portString string
+ fmt.Sprintf(portString, ":%d", port)
+ err = http.ListenAndServe(portString, nil)
+ if err != nil {
+
+ color.Printf("@r[%s]@{-} - run me as root!\n", xM)
+ return fmt.Errorf("%s\n", "failed to start httpd")
+ }
+
+ color.Printf("@g[%s]@{-}\n", checkM)
return nil
}
return nil
}
+func transposePage(writer http.ResponseWriter, req *http.Request) {
+
+ fqdn := req.URL.Path[4:]
+ targetURL := fmt.Sprintf("http://%s", fqdn)
+
+ resp, err := http.Get(targetURL)
+ if err != nil {
+
+ io.WriteString(writer, "failed to get that page! -kt\n")
+ io.WriteString(writer, targetURL)
+ return
+ }
+
+ var s scanner.Scanner
+ s.Init(req.Body)
+ //tok := s.Scan
+
+ resp.Body.Close()
+}
+
func main() {
err := ktInit("kolors", 999, "/home/kremlin/.Xresources")
func main() {
err := ktInit("kolors", 999, "/home/kremlin/.Xresources")
- /* make sure to close() anything you need to (you need to) */
- _, err = http.Get("http://kremlin.cc")
-
if err != nil {}
}
if err != nil {}
}