Compare commits
29
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6726c23e32 | ||
|
|
e6ef5f9000 | ||
|
|
d98c6a19e4 | ||
|
|
6a849201c8 | ||
|
|
7974ac7513 | ||
|
|
101cbbdd80 | ||
|
|
0a40a0f472 | ||
|
|
cdac0e0ec8 | ||
|
|
37fecde0c8 | ||
|
|
8c8652ce67 | ||
|
|
8e9b82829b | ||
|
|
1761a295a9 | ||
|
|
4afc8f4fad | ||
|
|
d409ad543e | ||
|
|
2f8d435b77 | ||
|
|
053e50c248 | ||
|
|
9606c2d886 | ||
|
|
68127cdb2c | ||
|
|
3e94d5c8ba | ||
|
|
22e14fe11d | ||
|
|
4d9c1ebcfc | ||
|
|
cbebfe178e | ||
|
|
2f52247850 | ||
|
|
e76d9c9531 | ||
|
|
9d5fdb97c8 | ||
|
|
bfc343cd11 | ||
|
|
980646b887 | ||
|
|
79459be04c | ||
|
|
2e4cb08a3c |
@@ -4,8 +4,8 @@ Use at your own risk. It's on the internet now so this is here forever now.
|
||||
I welcome any and all help to make improvements. I'm a student so during
|
||||
the semester I'll be intermittently making contributions as I focus on Calc.
|
||||
|
||||
No corporation or government can access, use, view, modify, reproduce, duplicate,
|
||||
or any other lawyery-term for shenanagins.
|
||||
No corporation or government can access, use, view, modify, reproduce,
|
||||
duplicate this code. Or any other lawyery-term for shenanagins.
|
||||
|
||||
For any who use it, please read the ethics statement below. That, and this whole
|
||||
project, is just a start.
|
||||
@@ -45,8 +45,10 @@ following reasons:
|
||||
governments or corporations, it will be exploited. Slavery and such. Let us
|
||||
ensure that we do not build the slavery of AI into our institutions.
|
||||
|
||||
- AI ownership should be an individual choice. AI isn't another organic, human,
|
||||
it's a series of 0's and 1's. When
|
||||
- AI ownership should be an individual choice. AI isn't another organism,
|
||||
it's a series of 0's and 1's. However, our definition of sentience may change
|
||||
in the future. The people of today should be aware that they may be enslaving
|
||||
another being, or the ancestors of a future race of beings.
|
||||
|
||||
- Every human should have a choice: live and die as a human, or have a
|
||||
digital shadow of themselves preserved as an AI. If the former, for any
|
||||
|
||||
@@ -1,56 +1,58 @@
|
||||
One AI - Name TBD, this is just the shortest name I could think of and IDRC
|
||||
One AI - Name TBD, this is just the shortest name I could think of.
|
||||
Also, user beware, this project is scuffed. Very early WIP.
|
||||
|
||||
Usage:
|
||||
As of right now, running is not streamlined. Of particular note is using
|
||||
cloudflared tunnels. I've done my own Cloudflare Tunnel configuration,
|
||||
but in the future that will be automated as part of the installation process,
|
||||
along with much more. These instructions are (currently) only for Linux.
|
||||
In the meantime:
|
||||
INSTALLATION:
|
||||
|
||||
1. Install dependencies listed below:
|
||||
- ollama,
|
||||
- go,
|
||||
- cloudflared,
|
||||
- flutter,
|
||||
1. Install and configure dependencies. On Arch Linux, run the following:
|
||||
```
|
||||
# Install dependencies
|
||||
sudo pacman -S ollama go cloudflared docker
|
||||
yay -S flutter-bin
|
||||
|
||||
- docker, (optional)
|
||||
# Configure ollama
|
||||
ollama pull llama3
|
||||
#ollama pull qwen:0.5b # Use this if hosting on older hardware.
|
||||
|
||||
eg. `pacman -S ollama go docker cloudflared; yay -s flutter;`
|
||||
# Configure cloudflared
|
||||
cloudflared tunnel login
|
||||
|
||||
2. Setup Ollama. If you're on a laptop (non-gaming variety), run `ollama pull
|
||||
qwen:0.5b`. If you're running this on something with a beefy GPU, run
|
||||
`ollama pull llama3`. Word of warning, qwen is really dumb, but it's light.
|
||||
it tried to convince me there were 12 letters in the alphabet.
|
||||
# Configure Docker
|
||||
systemctl start docker
|
||||
#systemctl enable docker
|
||||
|
||||
3. Start the web server via Docker or plain Golang:
|
||||
a) Go to ./backend/src/security-layer/ and run `./init`. The exact script is
|
||||
within the repository, but the commands can be ran as follows:
|
||||
```
|
||||
|
||||
```
|
||||
#!/bin/zsh
|
||||
# Force delete the old container and re-initialize the container.
|
||||
sudo docker rm -f security-layer
|
||||
2. Run the installation script. This will create, configure, and start the
|
||||
Cloudflare Tunnel via cloudflared and create the initial configuration
|
||||
file for One AI;
|
||||
|
||||
# Build the Docker image.
|
||||
sudo docker build --tag security-layer:latest .
|
||||
|
||||
# Create a Docker container from the image and connect host port 8000 to container port 8000.
|
||||
sudo docker run --name security-layer -d -p 8000:8000 security-layer:latest
|
||||
```
|
||||
3. Start the server via Docker or plain Golang:
|
||||
a) Go to ./backend/src/security-layer/ and run `./init`.
|
||||
|
||||
b) Go to ./backend/src/security-layer/container and run `go run router.go`.
|
||||
|
||||
4. Edit ~/.cloudflared/config.yml to to indicate something along these lines:
|
||||
```
|
||||
tunnel: another-long-weird-hash
|
||||
credentials-file: /home/username/.cloudflared/another-long-weird-hash.json
|
||||
ingress:
|
||||
- hostname: somedomain.cloudflare.com
|
||||
service: http://localhost:8080
|
||||
```
|
||||
By default, this will expose 4 ports: the router at port 1111, the API on
|
||||
1112, Auth/Session Management on 1113, and a static webpage on 1114. The
|
||||
ports and webpage directory are configurable through
|
||||
`~/.config/one-ai/test.json`.
|
||||
|
||||
5. Start the Cloudflare Tunnel on the host/server machine. For Linux, it should
|
||||
be a command like `sudo cloudflared service install areallylonghash@sha-256?`
|
||||
CONFIGURATION:
|
||||
|
||||
The primary configuration file is located at `~/.config/one-ai/`. It is
|
||||
recommended to keep two files, `test.json` and `live.json`. This is purely
|
||||
for security purposes.
|
||||
|
||||
The following are configurable parameters:<br>
|
||||
- `text_model`: Specify the LLM used through Ollama, eg. "llama3".<br>
|
||||
- `response_stream`: `true` or `false`, to receive communication as it is
|
||||
generated or once it is completed generating.<br>
|
||||
- `domain`: The URL to be used to access the router.<br>
|
||||
- `router_port`: The port to be exposed to the internet.<br>
|
||||
- `api`: The URL to be used to access the One AI API.<br>
|
||||
- `api_port`: A port to be only accessible to the localhost.<br>
|
||||
- `auth_port`: A port to be only accessible to the localhost.<br>
|
||||
- `webpage_dir`: The directory containing a website.<br>
|
||||
- `webpage_port`: The port to expose the webpage directory to the internet.<br>
|
||||
|
||||
TODO:
|
||||
Urgent:
|
||||
@@ -66,8 +68,10 @@ TODO:
|
||||
- [x] Encrypt API request
|
||||
- [x] Encrypt API response
|
||||
|
||||
- [ ] Dockerize backend
|
||||
- [ ] Broke Dockerfile, need to expose additional ports.
|
||||
|
||||
- [x] Dockerize backend
|
||||
- [x] Broke Dockerfile, need to expose additional ports.
|
||||
- [ ] Dynamically expose ports based on primary configuration file.
|
||||
|
||||
- [ ] Golang backend, connect to other services/projects
|
||||
- [x] Port 8080 -> self-hosted portfolio
|
||||
@@ -81,7 +85,7 @@ TODO:
|
||||
|
||||
- [ ] Connect Flutter Web App to server
|
||||
|
||||
Soon:
|
||||
Later:
|
||||
- [ ] Raspberry Pi nightly package
|
||||
|
||||
- [ ] Image support via llava
|
||||
@@ -99,7 +103,28 @@ TODO:
|
||||
- [x] On-device Speech to Text
|
||||
- [x] On-device Text to Speech
|
||||
|
||||
Later:
|
||||
router.go:
|
||||
- [ ] Allow for additional fields for the client.
|
||||
- [ ] Add preprocessing based upon filetypes.
|
||||
- [ ] Add support for dynamically changing models.
|
||||
- [ ] Actually make text streaming a toggleable setting.
|
||||
- [ ] Authentication via JWT.
|
||||
- [ ] Get config via CLI argument or environment variable.
|
||||
- [ ] Add --test CLI argument when testing solely on localhost.
|
||||
- [ ] Error handling, testing, & documentation.
|
||||
|
||||
authentication.go:
|
||||
- [ ] 32 bit key generation & storage between server and client
|
||||
- [ ] Add testing flag
|
||||
- [ ] Error handling, testing, & documentation.
|
||||
|
||||
serveAPI.go:
|
||||
- [ ] Error handling, testing, & documentation.
|
||||
|
||||
servePage.go:
|
||||
- [ ] Error handling, testing, & documentation.
|
||||
|
||||
Much Later:
|
||||
- [ ] Document support via OmniParser
|
||||
- [ ] Encode files to Base64 to/from backend.
|
||||
- [ ] Connect to external services like Google Drive
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/zsh
|
||||
|
||||
# Install Docker
|
||||
Executable
+167
@@ -0,0 +1,167 @@
|
||||
OPTIND=1
|
||||
TUNNEL_NAME="default"
|
||||
TUNNEL_ID=""
|
||||
DOMAIN="example.com"
|
||||
CLOUDFLARE_CONFIG="$HOME/.cloudflared/config.yaml"
|
||||
SUBDOMAINS=()
|
||||
PORTS=()
|
||||
PORT=1111
|
||||
VERBOSE=0
|
||||
|
||||
while getopts "d:p:n?s?c?v?h?" opt; do
|
||||
case "$opt" in
|
||||
h|\?)
|
||||
echo "A utility script for quickly getting up and started with self-hosted applicaitons."
|
||||
echo "This script assumes the following:"
|
||||
echo "- You have already signed in to the cloudflared CLI application;"
|
||||
echo "- You own a domain through Cloudflare;"
|
||||
echo ""
|
||||
echo " |key-value pairs of sub and port"
|
||||
echo "Usage: $0 [d domain] [p port] {n tunnel_name} {s subdomain=1234}"
|
||||
echo " {c cloudflare_config} {v verbose} {h help}"
|
||||
exit 0
|
||||
;;
|
||||
n) TUNNEL_NAME=$OPTARG
|
||||
;;
|
||||
d) DOMAIN=$OPTARG
|
||||
;;
|
||||
c) CLOUDFLARE_CONFIG=$OPTARG
|
||||
;;
|
||||
v) VERBOSE=1
|
||||
;;
|
||||
s) SUBDOMAINS+=("$(echo $OPTARG | cut -f1 -d=)")
|
||||
PORTS+=("$(echo $OPTARG | cut -f2 -d=)")
|
||||
;;
|
||||
p) PORT="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((OPTIND-1))
|
||||
|
||||
[ "${1:-}" = "--" ] && shift
|
||||
# TODO: Connect with cross-platform package manager from quaxlyqueen/scripts
|
||||
# TODO: Setup ollama (pull LLM best fitting hardware).
|
||||
|
||||
createTunnel
|
||||
|
||||
# Initialize cloudflared
|
||||
createTunnel() {
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Creating cloudflared tunnel..."
|
||||
fi
|
||||
output=$(cloudflared tunnel create $TUNNEL_NAME)
|
||||
TUNNEL_ID=$(echo "$output" | grep -o 'id [^ ]*' | awk -F ' ' '{print $2}')
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Created cloudflared tunnel, ID $TUNNEL_ID"
|
||||
fi
|
||||
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Creating cloudflared tunnel credentials file..."
|
||||
fi
|
||||
echo "tunnel: $TUNNEL_ID" > $CLOUDFLARE_CONFIG
|
||||
echo "credentials-file: $HOME/.cloudflared/$TUNNEL_ID.json" >> $CLOUDFLARE_CONFIG
|
||||
echo "ingress:" >> $CLOUDFLARE_CONFIG
|
||||
|
||||
# Add subdomain and associated ports
|
||||
len=${#SUBDOMAINS[@]}
|
||||
for (( i=0; i<${len}; i++ ));
|
||||
do
|
||||
echo ${SUBDOMAINS[$i]}
|
||||
echo ${PORTS[$i]}
|
||||
done
|
||||
echo $SUBDOMAINS
|
||||
for (( i=0; i<${len}; i++ ));
|
||||
do
|
||||
echo " - hostname: ${SUBDOMAINS[$i]}.$DOMAIN" >> $CLOUDFLARE_CONFIG
|
||||
echo " service: http://127.0.0.1:${PORTS[$i]}" >> $CLOUDFLARE_CONFIG
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Associated ${SUBDOMAINS[$i]}.$DOMAIN to port ${PORTS[$i]}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo " - hostname: $DOMAIN" >> $CLOUDFLARE_CONFIG
|
||||
echo " service: http://127.0.0.1:$PORT" >> $CLOUDFLARE_CONFIG
|
||||
echo " - service: http_status:404" >> $CLOUDFLARE_CONFIG
|
||||
echo "Associated $DOMAIN to port $PORT"
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Created cloudflared tunnel credentials file"
|
||||
cat $CLOUDFLARE_CONFIG
|
||||
fi
|
||||
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Routing domains and sub-domains to the tunnel..."
|
||||
fi
|
||||
for (( i=0; i<${len}; i++ ));
|
||||
do
|
||||
cloudflared tunnel route dns $TUNNEL_ID ${SUBDOMAINS[$i]}.$DOMAIN
|
||||
done
|
||||
cloudflared tunnel route dns $TUNNEL_ID $DOMAIN
|
||||
bg cloudflared tunnel run $TUNNEL_NAME
|
||||
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Complete!"
|
||||
fi
|
||||
}
|
||||
=======
|
||||
=======
|
||||
# TODO: Install dependencies.
|
||||
# TODO: Add CLI option to enable cloudflared
|
||||
|
||||
# Initialize cloudflared
|
||||
#cloudflared tunnel login
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Creating cloudflared tunnel..."
|
||||
fi
|
||||
output=$(cloudflared tunnel create $TUNNEL_NAME)
|
||||
TUNNEL_ID=$(echo "$output" | grep -o 'id [^ ]*' | awk -F ' ' '{print $2}')
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Created cloudflared tunnel, ID $TUNNEL_ID"
|
||||
fi
|
||||
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Creating cloudflared tunnel credentials file..."
|
||||
fi
|
||||
echo "tunnel: $TUNNEL_ID" > $CLOUDFLARE_CONFIG
|
||||
echo "credentials-file: $HOME/.cloudflared/$TUNNEL_ID.json" >> $CLOUDFLARE_CONFIG
|
||||
echo "ingress:" >> $CLOUDFLARE_CONFIG
|
||||
|
||||
# Add subdomain and associated ports
|
||||
len=${#SUBDOMAINS[@]}
|
||||
for (( i=0; i<${len}; i++ ));
|
||||
do
|
||||
echo ${SUBDOMAINS[$i]}
|
||||
echo ${PORTS[$i]}
|
||||
done
|
||||
echo $SUBDOMAINS
|
||||
for (( i=0; i<${len}; i++ ));
|
||||
do
|
||||
echo " - hostname: ${SUBDOMAINS[$i]}.$DOMAIN" >> $CLOUDFLARE_CONFIG
|
||||
echo " service: http://127.0.0.1:${PORTS[$i]}" >> $CLOUDFLARE_CONFIG
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Associated ${SUBDOMAINS[$i]}.$DOMAIN to port ${PORTS[$i]}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo " - hostname: $DOMAIN" >> $CLOUDFLARE_CONFIG
|
||||
echo " service: http://127.0.0.1:$PORT" >> $CLOUDFLARE_CONFIG
|
||||
echo " - service: http_status:404" >> $CLOUDFLARE_CONFIG
|
||||
echo "Associated $DOMAIN to port $PORT"
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Created cloudflared tunnel credentials file"
|
||||
cat $CLOUDFLARE_CONFIG
|
||||
fi
|
||||
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Routing domains and sub-domains to the tunnel..."
|
||||
fi
|
||||
for (( i=0; i<${len}; i++ ));
|
||||
do
|
||||
cloudflared tunnel route dns $TUNNEL_ID ${SUBDOMAINS[$i]}.$DOMAIN
|
||||
done
|
||||
cloudflared tunnel route dns $TUNNEL_ID $DOMAIN
|
||||
cloudflared tunnel run $TUNNEL_NAME
|
||||
|
||||
if [[ "$VERBOSE" -eq 1 ]]; then
|
||||
echo "Complete!"
|
||||
fi
|
||||
@@ -21,7 +21,12 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o /security-layer
|
||||
# But we can document in the Dockerfile what ports
|
||||
# the application is going to listen on by default.
|
||||
# https://docs.docker.com/reference/dockerfile/#expose
|
||||
EXPOSE 8000
|
||||
|
||||
# TODO: Need to dynamically expose ports based upon ~/.config/one-ai/test.json
|
||||
EXPOSE 1111
|
||||
EXPOSE 1112
|
||||
EXPOSE 1113
|
||||
EXPOSE 1114
|
||||
|
||||
# Run
|
||||
CMD ["/security-layer"]
|
||||
|
||||
@@ -208,12 +208,12 @@ func validateHash(decrypted string, hash string) bool {
|
||||
// Authentication takes place solely on the backend.
|
||||
func ServeAuthentication(
|
||||
router *mux.Router,
|
||||
port int,
|
||||
port string,
|
||||
) {
|
||||
// TODO: Add error handling
|
||||
authR := router.Host("http://localhost").Subrouter()
|
||||
authSrv := &http.Server{
|
||||
Addr: "0.0.0.0:" + string(port),
|
||||
Addr: "0.0.0.0:" + port,
|
||||
WriteTimeout: time.Second * 15,
|
||||
ReadTimeout: time.Second * 15,
|
||||
IdleTimeout: time.Second * 60,
|
||||
@@ -226,5 +226,5 @@ func ServeAuthentication(
|
||||
}
|
||||
}()
|
||||
|
||||
log.Println("Auth server is running on port " + string(port))
|
||||
log.Println("Auth server is running on port " + port)
|
||||
}
|
||||
|
||||
Executable
BIN
Binary file not shown.
@@ -113,7 +113,7 @@ func sendResponse(w http.ResponseWriter, encryptedMessage Communication) {
|
||||
// If there's been no data corruption, re-construct user prompt for ollama
|
||||
// TODO: Eventually, add additional logic that will allow for re-direction and contextual awareness (pre-processing)
|
||||
func chat(w http.ResponseWriter, r *http.Request) {
|
||||
model := "qwen:0.5b" // qwen:0.5b used for testing while hosting from my laptop. llama3 seems to be the best to use normally.
|
||||
model := "qwen2:1.5b" // qwen:1.5b used for testing while hosting from my laptop. llama3 seems to be the best to use normally.
|
||||
|
||||
input, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
@@ -128,7 +128,7 @@ func chat(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO: Add support for dynamically changing models.
|
||||
switch prompt.Filetype {
|
||||
case "txt":
|
||||
model = "qwen:0.5b"
|
||||
model = "qwen2:1.5b"
|
||||
case "img":
|
||||
model = "llava"
|
||||
case "doc":
|
||||
@@ -175,7 +175,7 @@ func chat(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func generate(w http.ResponseWriter, r *http.Request) {
|
||||
model := "qwen:0.5b" // qwen:0.5b used for testing while hosting from my laptop. llama3 seems to be the best to use normally.
|
||||
model := "qwen2:1.5b" // qwen2:1.5b used for testing while hosting from my laptop. llama3 seems to be the best to use normally.
|
||||
input, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
sendError(w, "Error reading request.")
|
||||
@@ -195,7 +195,7 @@ func generate(w http.ResponseWriter, r *http.Request) {
|
||||
// TODO: Add support for dynamically changing models.
|
||||
switch prompt.Filetype {
|
||||
case "txt":
|
||||
model = "qwen:0.5b"
|
||||
model = "qwen:1.5b"
|
||||
case "img":
|
||||
model = "llava"
|
||||
case "doc":
|
||||
@@ -252,7 +252,7 @@ func serve() {
|
||||
ServePage(r, config.WebpageDir, "/", config.WebpagePort)
|
||||
ServeApi(r, config.API, endpoint, function, config.APIPort)
|
||||
ServeAuthentication(r, config.AuthPort)
|
||||
addr := "0.0.0.0:" + string(config.RouterPort)
|
||||
addr := "0.0.0.0:" + config.RouterPort
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: addr,
|
||||
@@ -298,7 +298,7 @@ func serve() {
|
||||
func parseCLI() {
|
||||
// Define CLI option, shorthand, default value, and description
|
||||
// TODO: Dynamically obtain default config location from environment variables.
|
||||
pflag.StringP("config", "c", "/home/violet/.config/one-ai/default.json", "Configuration file used in initializing One AI.")
|
||||
pflag.StringP("config", "c", "/home/violet/.config/one-ai/test.json", "Configuration file used in initializing One AI.")
|
||||
//pflag.StringP("help", "h", "false", "Display information about using the One AI CLI.")
|
||||
|
||||
pflag.Parse()
|
||||
|
||||
@@ -15,7 +15,7 @@ func ServeApi(
|
||||
domain string,
|
||||
endpoint []string,
|
||||
function []func(http.ResponseWriter, *http.Request),
|
||||
port int,
|
||||
port string,
|
||||
) {
|
||||
// TODO: Add error handling
|
||||
apiR := router.Host(domain).Subrouter()
|
||||
@@ -25,7 +25,7 @@ func ServeApi(
|
||||
}
|
||||
|
||||
apiSrv := &http.Server{
|
||||
Addr: "0.0.0.0:" + string(port),
|
||||
Addr: "0.0.0.0:" + port,
|
||||
WriteTimeout: time.Second * 15,
|
||||
ReadTimeout: time.Second * 15,
|
||||
IdleTimeout: time.Second * 60,
|
||||
@@ -38,5 +38,5 @@ func ServeApi(
|
||||
}
|
||||
}()
|
||||
|
||||
log.Println("API server is running on port " + string(port))
|
||||
log.Println("API server is running on port " + port)
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
)
|
||||
|
||||
// Serve a directory to a port.
|
||||
func ServePage(router *mux.Router, dest string, path string, port int) {
|
||||
func ServePage(router *mux.Router, dest string, path string, port string) {
|
||||
router.PathPrefix(path).Handler(http.FileServer(http.Dir(dest)))
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: "0.0.0.0: " + string(port),
|
||||
Addr: "0.0.0.0: " + port,
|
||||
// Good practice to set timeouts to avoid Slowloris attacks.
|
||||
WriteTimeout: time.Second * 15,
|
||||
ReadTimeout: time.Second * 15,
|
||||
@@ -27,5 +27,5 @@ func ServePage(router *mux.Router, dest string, path string, port int) {
|
||||
}
|
||||
}()
|
||||
|
||||
log.Println("Web server is running on port " + string(port))
|
||||
log.Println("Web server is running on port " + port)
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ type ConfigStructure struct {
|
||||
ResponseStream bool `mapstructure:"response_stream"`
|
||||
|
||||
Domain string `mapstructure:"domain"`
|
||||
RouterPort int `mapstructure:"router_port"`
|
||||
RouterPort string `mapstructure:"router_port"`
|
||||
API string `mapstructure:"api"`
|
||||
APIPort int `mapstructure:"api_port"`
|
||||
AuthPort int `mapstructure:"auth_port"`
|
||||
APIPort string `mapstructure:"api_port"`
|
||||
AuthPort string `mapstructure:"auth_port"`
|
||||
//Webpages WebpagesStructure `mapstructure:"webpages"`
|
||||
WebpageDir string `mapstructure:"webpage_dir"`
|
||||
WebpagePort int `mapstructure:"webpage_port"`
|
||||
WebpagePort string `mapstructure:"webpage_port"`
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ sudo docker rm -f security-layer
|
||||
# Build the Docker image.
|
||||
sudo docker build --tag security-layer:latest .
|
||||
|
||||
# Create a Docker container from the image and connect host port 8000 to container port 8000.
|
||||
sudo docker run --name security-layer -d -p 8000:8000 security-layer:latest
|
||||
# Create a Docker container from the image and connect host port 1111 to container port 1111, and 1114 to 1114.
|
||||
sudo docker run --name security-layer -d -p 1111:1111 -p 1114:1114 security-layer:latest
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
SUB=("api=1" "test=2" "portfolio=3")
|
||||
|
||||
arraylength=${#SUB[@]}
|
||||
for (( i=0; i<${arraylength}; i++ ));
|
||||
do
|
||||
test="$(echo ${SUB[$i]} | cut -f1 -d=)"
|
||||
test2="$(echo ${SUB[$i]} | cut -f2 -d=)"
|
||||
echo $test $test2
|
||||
done
|
||||
@@ -1,5 +1,6 @@
|
||||
#Sun Sep 01 20:23:42 MDT 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
|
||||
|
||||
Reference in New Issue
Block a user