Documentation

This commit is contained in:
Marc Ole Bulling
2021-03-28 22:09:48 +02:00
parent cf971b0fc2
commit d9fbcce75b
8 changed files with 26 additions and 43 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@ SingleDownload
config/
data/
.idea/
Gokapi

View File

@@ -1,5 +1,9 @@
package main
/**
Loading and saving of the persistent configuration
*/
import (
"encoding/json"
"fmt"
@@ -9,9 +13,6 @@ import (
"strings"
)
/**
Loading and saving of the persistent configuration
*/
// Name of the config dir that will be created
const configDir = "config"
@@ -181,4 +182,4 @@ func isValidUrl(url string) bool {
return false
}
return true
}
}

View File

@@ -1,24 +0,0 @@
FROM golang:1.16 AS build_base
## Usage:
## docker build . -t gokapi
## docker run -it -v gokapi-data:/app/data -v gokapi-config:/app/config -p 127.0.0.1:53842:53842 gokapi
RUN mkdir /compile
COPY go.mod /compile
RUN cd /compile && go mod download
COPY . /compile
RUN cd /compile && CGO_ENABLED=0 go build -ldflags="-s -w -X 'main.IS_DOCKER=true' -X 'main.BUILDER=Docker Testing' -X 'main.BUILD_TIME=$(date)'" -o /compile/gokapi
FROM alpine:3.13
RUN apk add ca-certificates && mkdir /app && touch /app/.isdocker
COPY --from=build_base /compile/gokapi /app/gokapi
WORKDIR /app
CMD ["/app/gokapi"]

View File

@@ -1,5 +1,9 @@
package main
/**
Serving and processing uploaded files
*/
import (
"crypto/sha1"
"encoding/hex"
@@ -11,9 +15,6 @@ import (
"time"
)
/**
Serving and processing uploaded files
*/
// The length for IDs used in URLs. Can be increased to improve security and decreased to increase readability
const lengthId = 15

View File

@@ -1,5 +1,9 @@
package main
/**
Various functions, mostly for OS access
*/
import (
"bufio"
cryptorand "crypto/rand"
@@ -13,9 +17,6 @@ import (
"strings"
)
/**
Various functions, mostly for OS access
*/
// Hashes a password with SHA256 and a salt
func hashPassword(password, salt string) string {

View File

@@ -1,5 +1,9 @@
package main
/**
Main routine
*/
import (
"fmt"
"math/rand"
@@ -7,9 +11,6 @@ import (
"time"
)
/**
Main routine
*/
// needs to be changed in ./templates/string_constants.tmpl as well
const VERSION = "1.1.0"

View File

@@ -1,13 +1,14 @@
package main
/**
Manages the sessions for the admin user or to access password protected files
*/
import (
"net/http"
"time"
)
/**
Manages the sessions for the admin user or to access password protected files
*/
//If no login occurred during this time, the admin session will be deleted. Default 30 days
const COOKIE_LIFE_ADMIN = 30 * 24 * time.Hour

View File

@@ -1,5 +1,9 @@
package main
/**
Handling of webserver and requests / uploads
*/
import (
"embed"
"fmt"
@@ -15,9 +19,6 @@ import (
"time"
)
/**
Handling of webserver and requests / uploads
*/
// Embedded version of the "static" folder
// This contains JS files, CSS, images etc