Skip to content

Commit

Permalink
crystal-gchat-server 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mixflame committed Jul 26, 2020
0 parents commit 8bc02e5
Show file tree
Hide file tree
Showing 14 changed files with 676 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf
buffer.txt
messages.txt
config.yml
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: crystal

# Uncomment the following if you'd like Travis to run specs and check code formatting
# script:
# - crystal spec
# - crystal tool format --check
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 your-name-here

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
all: bin

test:
crystal spec

bin: clean
crystal build -s --release -o crystal-gchat-server src/crystal-gchat-server.cr
crystal build -s --release -o change-passwords src/change-passwords.cr

clean:
rm -f crystal-gchat-server
rm -f change-passwords

run:
crystal run src/crystal-gchat-server.cr
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# crystal-gchat-server

Asynchronous Chat and Drawing server

## Installation

Install Crystal 0.35.1

Optionally edit variables at the top of crystal-gchat-server.cr

Run `crystal src/crystal-gchat-server.cr`

## Usage

To be used with the GlobalChat2 client.

## Development

Runs on Crystal 0.35.1 with no shards

## Contributing

1. Fork it (<https://github.com/your-github-user/crystal-gchat-server/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Contributors

- [Jonathan Silverman](https://github.com/mixflame) - creator and maintainer
Binary file added change-passwords
Binary file not shown.
Binary file added crystal-gchat-server
Binary file not shown.
10 changes: 10 additions & 0 deletions shard.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2.0
shards:
atomic_write:
git: https://github.com/chris-huxtable/atomic_write.cr.git
version: 0.1.5

sodium:
git: https://github.com/didactic-drunk/sodium.cr.git
version: 1.2.0

26 changes: 26 additions & 0 deletions shard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: crystal-gchat-server
version: 1.0.0

authors:
- Jonathan Silverman <jsilverman2@gmail.com>

description: |
A high performance server for the GlobalChat2 protocol,
allowing clients chat, collaborative image editing
and secure E2E encrypted private messages.
dependencies:
atomic_write:
github: chris-huxtable/atomic_write.cr
sodium:
github: didactic-drunk/sodium.cr

targets:
crystal-gchat-server:
main: src/crystal-gchat-server.cr
change-passwords:
main: src/change-passwords.cr

crystal: 0.35.1

license: MIT
9 changes: 9 additions & 0 deletions spec/crystal-gchat-server_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require "./spec_helper"

describe Crystal::Gchat::Server do
# TODO: Write tests

it "works" do
false.should eq(true)
end
end
2 changes: 2 additions & 0 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require "spec"
require "../src/crystal-gchat-server"
64 changes: 64 additions & 0 deletions src/change-passwords.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require "yaml"
require "crypto/bcrypt/password"
require "option_parser"
require "atomic_write"
require "big"

module Globals
def self.interactive
puts "enter server name"
server_name = gets.to_s.chomp

puts "enter port"
port = gets.to_s.chomp.to_i

puts "enter login password"
password = Crypto::Bcrypt::Password.create(gets.to_s.chomp, cost: 10).to_s

puts "enter admin password"
admin_password = Crypto::Bcrypt::Password.create(gets.to_s.chomp, cost: 10).to_s

puts "should appear in server list? y/n"
is_private = gets.to_s.chomp == "n"

puts "canvas size in widthxheight"
canvas_size = gets.to_s.chomp

puts "serverside chat replay (scrollback) y/n"
scrollback = gets.to_s.chomp == "y"

puts "how many lines to replay?"
buffer_line_limit = gets.to_s.chomp.to_i

puts "server file size limit (canvas, replay) in bytes (ie 10e+7 for 100 megabytes)"
file_size_limit = gets.to_s.chomp.to_f64

File.atomic_write("config.yml") { |f| YAML.dump({
server_name: server_name,
port: port,
password: password,
admin_password: admin_password,
is_private: is_private,
canvas_size: canvas_size,
scrollback: scrollback,
buffer_line_limit: buffer_line_limit,
file_size_limit: file_size_limit,
}, f) }

exit
end

OptionParser.parse do |parser|
parser.banner = "Usage: change-password [arguments]"
parser.on("-i", "--interactive", "Enter the config options from the terminal") { Globals.interactive }
parser.on("-h", "--help", "Show this help") do
puts parser
exit
end
parser.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option."
STDERR.puts parser
exit(1)
end
end
end

0 comments on commit 8bc02e5

Please sign in to comment.