feat: nix build
This commit is contained in:
parent
f796973fbd
commit
5417d4d475
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ __debug_bin*
|
|||
.vscode
|
||||
|
||||
.coverage
|
||||
result
|
||||
|
|
16
default.nix
Normal file
16
default.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
pkgs.buildGoModule {
|
||||
pname = "wormspace";
|
||||
version = "1.0.0";
|
||||
|
||||
src = pkgs.lib.cleanSource ./.;
|
||||
|
||||
vendorHash = "sha256-p0W/ubYYbIpmq7D7AN6CIF421nnURbZUX5rGAkbmwiI=";
|
||||
|
||||
|
||||
meta = {
|
||||
description = "XSS Worm demo";
|
||||
homepage = "https://tea.filefighter.de/qvalentin/wormspace";
|
||||
};
|
||||
}
|
15
main.go
15
main.go
|
@ -4,6 +4,8 @@ import (
|
|||
"bytes"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
|
@ -229,6 +231,7 @@ func profilePage(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
tmpl := template.Must(template.New("profile").Parse(`
|
||||
<html><body>
|
||||
<!-- contribute at https://tea.filefighter.de/qvalentin/wormspace -->
|
||||
<nav>
|
||||
<a href="/home">Home</a> | <a href="/profile?name={{.User.Name}}">My Profile</a>
|
||||
</nav>
|
||||
|
@ -259,6 +262,7 @@ func homePage(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
tmpl := template.Must(template.New("home").Parse(`
|
||||
<html><body>
|
||||
<!-- contribute at https://tea.filefighter.de/qvalentin/wormspace -->
|
||||
<nav>
|
||||
<a href="/home">Home</a> | <a href="/profile?name={{.User.Name}}">My Profile</a>
|
||||
</nav>
|
||||
|
@ -276,6 +280,7 @@ func homePage(w http.ResponseWriter, r *http.Request) {
|
|||
func indexPage(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl := template.Must(template.New("index").Parse(`
|
||||
<html><body>
|
||||
<!-- contribute at https://tea.filefighter.de/qvalentin/wormspace -->
|
||||
<h1>Welcome to Wormspace</h1>
|
||||
<form action="/setuser" method="POST">
|
||||
<input name="username" placeholder="Enter your username">
|
||||
|
@ -294,5 +299,13 @@ func main() {
|
|||
http.HandleFunc("/addpost", addPost)
|
||||
http.HandleFunc("/addhero", addHero)
|
||||
|
||||
http.ListenAndServe(":8080", nil)
|
||||
port := 8080
|
||||
|
||||
// get port from arg
|
||||
if len(os.Args) > 1 {
|
||||
port, _ = strconv.Atoi(os.Args[1])
|
||||
}
|
||||
|
||||
fmt.Println("Listening on http://localhost:" + strconv.Itoa(port))
|
||||
http.ListenAndServe(":"+strconv.Itoa(port), nil)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue