-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.sh
More file actions
executable file
·62 lines (58 loc) · 1.72 KB
/
Copy pathnode.sh
File metadata and controls
executable file
·62 lines (58 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Determine the operating system
if [[ "$OSTYPE" == "msys" ]]; then
GRPCURL="grpcurl.exe"
else
GRPCURL="grpcurl"
fi
# Prompt for API key (optional)
echo "Enter API key (leave blank to skip):"
read APIKEY
if [[ -n "$APIKEY" ]]; then
APIKEY_HEADER="-H"
APIKEY_VALUE="x-api-key: $APIKEY"
else
APIKEY_HEADER=""
APIKEY_VALUE=""
fi
while true; do
echo "Select an option to test the proto server:"
echo "1. Ping"
echo "2. Send"
echo "3. Receive"
echo "4. Cleanup"
echo "5. Exit"
read -p "Enter your choice: " choice
case $choice in
1)
$GRPCURL $APIKEY_HEADER "$APIKEY_VALUE" -d '{"from":"node1"}' -import-path $(pwd)/base/ -proto base.proto -plaintext localhost:9000 base.proto.Broker/Ping
;;
2)
echo "Enter message data:"
read data
echo "Enter sender (from):"
read from
echo "Enter receiver (to):"
read to
base64_data=$(echo -n "$data" | base64)
$GRPCURL $APIKEY_HEADER "$APIKEY_VALUE" -d '{"data":"'$base64_data'", "queue":"true", "type":"TEXT", "from":"'$from'", "to":"'$to'"}' -import-path $(pwd)/base/ -proto base.proto -plaintext localhost:9000 base.proto.Broker/Send
;;
3)
echo "Enter sender (from):"
read from
$GRPCURL $APIKEY_HEADER "$APIKEY_VALUE" -d '{"from":"'$from'"}' -import-path $(pwd)/base/ -proto base.proto -plaintext localhost:9000 base.proto.Broker/Receive
;;
4)
echo "Enter sender (from):"
read from
$GRPCURL $APIKEY_HEADER "$APIKEY_VALUE" -d '{"from":"'$from'"}' -import-path $(pwd)/base/ -proto base.proto -plaintext localhost:9000 base.proto.Broker/Cleanup
;;
5)
echo "Exiting..."
break
;;
*)
echo "Invalid choice"
;;
esac
done