Skip to content

Commit

Permalink
v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
espidev committed Apr 24, 2018
1 parent dcaf933 commit 4ba8453
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 2 deletions.
Binary file renamed main → ClioteSky
Binary file not shown.
31 changes: 31 additions & 0 deletions buildEverything.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
cd src/main

package=$1
if [[ -z "$package" ]]; then
echo "usage: $0 <package-name>"
exit 1
fi
package_split=(${package//\// })
package_name=${package_split[-1]}

platforms=("darwin/386" "darwin/amd64" "dragonfly/amd64" "freebsd/386" "freebsd/amd64" "freebsd/arm" "linux/386" "linux/amd64" "linux/arm" "linux/arm64" "linux/ppc64" "linux/ppc64le" "linux/mips" "linux/mipsle" "linux/mips64"
"linux/mips64le" "netbsd/386" "netbsd/amd64" "netbsd/arm" "openbsd/386" "openbsd/amd64" "openbsd/arm" "windows/amd64" "windows/386" "solaris/amd64" "plan9/386" "plan9/amd64")

for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name='esticonsole-'$GOOS'-'$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi

env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name $package
mv $output_name ../../bin
if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi
done
71 changes: 69 additions & 2 deletions src/main/cliotesky.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
"time"
"google.golang.org/grpc/credentials"
"sync"
"bufio"
"io"
"strings"
)

var (
Expand Down Expand Up @@ -102,12 +105,69 @@ func main() {
log.Fatal("Unable to use tls key files, check the directory. " + csConfig.CertFile + " : " + csConfig.KeyFile + ". Error: " + err.Error())
}

go startCommands() //start command line

grpcServer = grpc.NewServer(grpc.Creds(creds))
pb.RegisterClioteSkyServiceServer(grpcServer, &ClioteSkyService{})
fmt.Println("Starting gRPC Server...")
grpcServer.Serve(lis)
}

func startCommands() {
var reader = bufio.NewReader(os.Stdin)
for { //command line loop
input, err := reader.ReadString('\n')
if err == io.EOF {
time.Sleep(100 * time.Millisecond)
continue
}
if err != nil {
println(err.Error())
}
input = strings.TrimRight(input, "\n")
str := strings.Split(input, " ")
switch str[0] {
case "help":
fmt.Println("-----Help-----")
fmt.Println("cliotes | List all of the cliotes.")
fmt.Println("requests | List all of the requests waiting for cliotes.")
fmt.Println("tokens | List the token allocation.")
break
case "cliotes":
fmt.Println("Categories:\n-----------")
f := func(key, value interface{}) bool {
fmt.Println(key.(string) + ":")
for _, cliote := range value.([]string) {
fmt.Println(" " + cliote)
}
return true
}

cliotes.Range(f)
break
case "requests":
fmt.Println("Messages:\n----------")
f := func(key, value interface{}) bool {
fmt.Println(key.(string) + ":")
for _, message := range value.([]pb.ClioteMessage) {
fmt.Println(message.Sender + " " + message.Identifier + " " + string(message.Data))
}
return true
}
requests.Range(f)
break
case "tokens":
fmt.Println("Tokens:\n----------")
f := func(key, value interface{}) bool {
fmt.Println(key.(string) + " : " + value.(string))
return true
}
tokens.Range(f)
break
}
}
}

// gRPC Implemented Functions

func (clioteskyservice *ClioteSkyService) Request(token *pb.Token, stream pb.ClioteSkyService_RequestServer) error {
Expand All @@ -123,7 +183,6 @@ func (clioteskyservice *ClioteSkyService) Request(token *pb.Token, stream pb.Cli
}
}
requests.Delete(user)
fmt.Println(requests)
}
return nil
}
Expand Down Expand Up @@ -161,7 +220,15 @@ func (clioteskyservice *ClioteSkyService) Auth(ctx context.Context, auth *pb.Aut

if _, ok := cliotes.Load(auth.Category); ok {
v, _ := cliotes.Load(auth.Category)
cliotes.Store(auth.Category, append(v.([]string), auth.User))
add := true
for _, val := range v.([]string) {
if val == auth.User {
add = false
}
}
if (add) {
cliotes.Store(auth.Category, append(v.([]string), auth.User))
}
} else {
cliotes.Store(auth.Category, []string{auth.User})
}
Expand Down

0 comments on commit 4ba8453

Please sign in to comment.