Skip to content

Commit

Permalink
Don't allow spaces in usernames
Browse files Browse the repository at this point in the history
Update PROTOCOL and README
Added -f flag to clean target in frontend Makefile
  • Loading branch information
Arc676 committed Sep 2, 2018
1 parent 4d0c6e5 commit 5eae4da
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ Once a successful socket connection is established, the registration process beg

- The username cannot be one of the five reserved usernames (Server, Error, Info, Notice, TERM)
- The username cannot be in use by another connected client
- The username cannot contain spaces

If the username can be used, the server replies with `"K"`. Otherwise, it replies with `"N"`. If registration fails, the server drops the connection immediately. Clients should terminate or give up connecting at this point. A new connection must be made to re-register.

The connecting client must provide a username within 5 seconds. If the server is forced to wait longer than this duration, the connection is dropped.

## Communication

### Format
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ The SockTalk protocol is a simple, open-source network communication protocol. C
Compiling SockTalk requires that the OpenSSL library be installed.

## Frontend commands
- "/close" from server side closes server socket.
- "/disconnect" from client side disconnects from server.
- "/help" gives a list of commands supported by the server.

- `/close` - from server side closes server socket.
- `/disconnect` - from client side disconnects from server.
- `/help` - gives a list of commands supported by the server.
- `/kick`, `/ban`, `/unban` - prompts for a username and kicks/bans/unbans the user with the given username

## Legal

Expand Down
2 changes: 1 addition & 1 deletion lib/socktalkserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void SockTalkServer::addHandler(SockTalkClientHandler* ch) {
}

bool SockTalkServer::isReservedName(const std::string &username) {
return username == "Server" || username == "Info" || username == "Error" || username == "Notice" || username == "TERM";
return username == "Server" || username == "Info" || username == "Error" || username == "Notice" || username == "TERM" || username.find(" ") != std::string::npos;
}

bool SockTalkServer::registerName(const std::string &username, const std::string &IP) {
Expand Down
2 changes: 1 addition & 1 deletion stclient/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ server:
$(CC) $(FLAGS) $(LD) server.cpp $(LIB) $(THREAD) -o server

clean:
rm server client
rm -f server client

0 comments on commit 5eae4da

Please sign in to comment.