3 Commits

Author SHA1 Message Date
oracle ae02c9dfc0 EKHO-13 | justfile
created justfile, added service file
2026-06-20 00:57:46 -04:00
oracle fae2cceae2 WIP adding names 2026-06-19 00:38:57 -04:00
oracle 552f9ac9c2 removed ghost line bug AGAIN and tested with go1.26.2 (arch btw) 2026-04-28 20:14:33 -04:00
5 changed files with 61 additions and 106 deletions
-30
View File
@@ -1,30 +0,0 @@
server_clean:
rm server
client_clean:
rm client
clean: server_clean client_clean
server:
go build server.go
client:
go build client.go
build: server client
ins_server:
go build -o ekho_server server.go
mv ekho_server /usr/local/bin/
cp ekho.service /etc/systemd/system/ekho.service
mkdir -p ~/.config/ekho
ln -s -r ./list.q ~/.config/ekho/list.q
systemctl daemon-reload
systemctl enable ekho
systemctl start ekho
systemctl status ekho
ins_client:
go build -o ekho client.go
mv ekho /usr/local/bin/
+43 -47
View File
@@ -3,84 +3,80 @@
## Why? ## Why?
To test my abilities to develop networked programs, and to enhance my skills in writing such. To test my abilities to develop networked programs, and to enhance my skills in writing such.
## Requirements ## Requirements
### Hardware ### Hardware
- Client machine - Client machine
- Server machine (not required to be distinct from Client) - Server machine (not required to be distinct from Client)
### Software ### Software
- Tested with [golang] v1.26 - [Golang]
- Installation has only been tested with [just] v1.53 - Linux distro (highly recommened)
- Server installation assumes systemd (tested with v260.2) - ```make``` is also used in this guide, but the makefile is incredibly simple, and can be skipped entirely by running ```go build``` instead
### Installation ### Installation
Golang can be installed on Mac with
``` sh
brew install golang
```
Clone the repo Clone the repo
``` sh ``` sh
git clone https://github.com/alexander-the-alright/ekho git clone https://github.com/alexander-the-alright/ekho
cd ekho cd ekho
``` ```
Using your favorite text editor, change the destination IP and Port to whatever works for you. This is defined on line 247 in client.go as 127.0.0.1:1300.
#### Justfile Now the server file needs to be run on the preferred port, as specified in the client file. This is defined on line 257 in server.go.
It is recommended to use ```just``` for installation, as it has more
capabilities than ```make```, however, there is a makefile included.
To install the server with ```just```, run ```sudo just ins_server```.
You will be prompted to enter a new port number to run the server on (
or leave blank to use 1300). The port will be changed in the source
file before compilation.
To install the client with ```just```, run ```sudo just ins_client```.
You will be prompted to enter the IP (or URL) and port of the server
(or leave blank to use localhost:1300). The IP/URL and port will be
changed in the source file before compilation.
#### Makefile
If you are unable or willing to use ```just```, the included makefile
still has most of the functionality, but it does not change any
important parameters. The following changes are advised before
installation.
1. On the client machine, change the IP/URL and port in the client source file. This can be The binary(s) can be obtained using the makefile
done quickly with ```sed -i -e "s/127.0.0.1:1300/YOUR.IP.GOES.HERE:PORT/" client.go``` If the server is being run on a separate machine, only run make with client flag
2. On the server machine, change the port in the server source file. This can be done with a ``` sh
similar command: ```sed -i -e "s/1300/PORT/" server.go```. (note: this make client
should match the port from bullet 1) ```
3. On the server machine, change the user referenced in the systemd service file. This can be If both binaries are being run on the same machine, ```make all``` will suffice. Although, both of these commands can be bypassed with ```go build```, as this is all ```make``` does anyway.
done with another sed command, ```sed -e -i "s/USER/YOUR_USERNAME/" ekho.service``` ``` sh
make all
```
After making these changes on the respective machines, run either #### NOTE
```sudo make ins_client``` or ```sudo make ins_server``` to compile and install the client In previous versions, the suggested method of installation involved placing bash scripts in ```/etc/update-motd.d/```, however, there have been issues getting that installation method working (namely, having MOTD run user-defined commands), and the current quick and extremely dirty suggested installation method is to just append the user's shell config files (```.bashrc```, ```.bash_profile```, ```.zshrc```, etc) with the paths to the executables.
and/or server binaries.
#### After Installation For example, if the server used zsh, the installation could look something like this:
After installation of the server binary, systemd will display the ``` sh
status of the new service. It should be ```enabled``` and echo "~/abs/path/to/server.o &" >> ~/.zshrc
```running```. ```
Similarly for a client using Bash:
``` sh
echo "~/abs/path/to/client.o" >> ~/.bashrc
```
Any help figuring out the issue with MOTD would be appreciated.
Finally done! Finally done!
### Usage ### Usage
The client uses the following flags The client uses the following flags
``` sh ``` sh
-h - display help message -h - display help message
-a <string> - adds required argument <s> as a quote to server -a <s> - adds required argument <s> as a quote to server
-ip <ip:port> - specify alternate server destination
-l - list all quotes -l - list all quotes
-r [i] - remove; may be run with or without argument -r [i] - remove; may be run with or without argument
-s <i> - specify the size of the receipt buffer -ip - specify alternate server destination
-s - specify the size of the receipt buffer
``` ```
The server uses the following flags The server uses the following flags
``` sh ``` sh
-h - display help message -h - display help message
-s <i> - specify the size of the receipt buffer -s - specify the size of the receipt buffer
-v - display version and exit
-vv - display version and about info and exit
``` ```
### How It Works
The sequence diagram can be viewed in ```diag``` folder, which shows the sequence of networked messages for each usage of ekho.
The source code is in the same folder, ```ekho-seq.txt```, and can be uploaded to [sequencediagram.org][seqdiag] to rerender the diagram and view any updates.
### To Be Implemented ### To Be Implemented
- Log all uses/transaction data each day - Log all uses/transaction data each day
- Request, send, and receive the logfile - Request, send, and receive the logfile for any day
- User-specific quotes/quotefiles - User-specific quotes/quotefiles
- Colored printing and coloring quotes - Installation (client-side, at least) via MOTD
- Edit quotes
[golang]: <https://go.dev/doc/install> [golang]: <https://go.dev/doc/install>
[just]: <https://github.com/casey/just> [seqdiag]: <sequencediagram.org>
+1 -1
View File
@@ -339,7 +339,7 @@ func main() {
flag.BoolVar( &add, "a", false, "add quote to list" ) flag.BoolVar( &add, "a", false, "add quote to list" )
flag.BoolVar( &remove, "r", false, "remove quote from list" ) flag.BoolVar( &remove, "r", false, "remove quote from list" )
flag.BoolVar( &list, "l", false, "print quote list" ) flag.BoolVar( &list, "l", false, "print quote list" )
flag.StringVar( &dest, "ip", "127.0.0.1:1300", "ip:port of server" ) flag.StringVar( &dest, "ip", "earth-1.net:1300", "ip:port of server" )
flag.IntVar( &tsize, "s", 256, "transmission size ( bytes )" ) flag.IntVar( &tsize, "s", 256, "transmission size ( bytes )" )
flag.Parse() // process flags flag.Parse() // process flags
+3 -3
View File
@@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
Restart=always Restart=always
RestartSec=5 RestartSec=5
User=USER User=
ExecStart=/usr/local/bin/ekho_server ExecStart=/usr/local/bin/server
WorkingDirectory=/home/USER/.config/ekho WorkingDirectory=/home/
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
+11 -22
View File
@@ -33,37 +33,26 @@ ins_server:
if [[ $PORT -ne "" ]]; then if [[ $PORT -ne "" ]]; then
sed -i -e "s/1300/$PORT/" server.go sed -i -e "s/1300/$PORT/" server.go
fi fi
echo "go build -o ekho_server server.go" echo "go build server.go"
go build -o ekho_server server.go go build server.go
echo "mv ekho_server /usr/local/bin/"
mv ekho_server /usr/local/bin/
USER=($(users)) USER=($(users))
sed -i -e "s/USER/${USER[0]}/" ekho.service sed -i -e "s/^User=/User=${USER[0]}/" ekho.service
echo "cp ekho.service /etc/systemd/system/" sed -i -e "s/^WorkingDirectory=.*/WorkingDirectory=\/home\/${USER[0]}\//" ekho.service
cp ekho.service /etc/systemd/system/ echo "sudo mv server /usr/local/bin/server"
mkdir -p ~/.config/ekho sudo mv server /usr/local/bin/server
echo "ln -s -r ./list.q ~/.config/ekho/list.q" echo "sudo mv ekho.service /etc/systemd/system/"
ln -s -r ./list.q ~/.config/ekho/list.q sudo mv ekho.service /etc/systemd/system/
echo "systemctl daemon-reload"
systemctl daemon-reload
echo "systemctl enable ekho"
systemctl enable ekho
echo "systemctl start ekho"
systemctl start ekho
echo "systemctl status ekho"
systemctl status ekho
# install client # install client
ins_client: ins_client:
#!/usr/bin/bash #!/usr/bin/bash
echo "enter url or ip and port of server, 'aaa.bbb.ccc.ddd:port" echo "enter ip and port of server, 'aaa.bbb.ccc.ddd:port"
read IP_PORT read IP_PORT
sed -i -e "s/:1300/$IP_PORT/" client.go sed -i -e "s/:1300/$IP_PORT/" client.go
echo "go build -o ekho client.go" echo "go build -o ekho client.go"
go build -o ekho client.go go build -o ekho client.go
sed -i -e "s/$IP_PORT/:1300/" client.go sed -i -e "s/$IP_PORT/:1300/" client.go
echo "mv ekho /usr/local/bin/" echo "sudo mv ekho /usr/local/bin/"
mv ekho /usr/local/bin/ sudo mv ekho /usr/local/bin/
echo "add 'ekho' to shell config (config.fish, .bashrc, etc)" echo "add 'ekho' to shell config (config.fish, .bashrc, etc)"