more
This commit is contained in:
parent
279faa56b7
commit
89c2398a96
3
contrib/backends/nntpchan-daemon/.gitignore
vendored
3
contrib/backends/nntpchan-daemon/.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
*.o
|
*.o
|
||||||
*.a
|
*.a
|
||||||
nntpd
|
nntpd
|
||||||
nntpchan-tool
|
tools/authtool
|
||||||
|
tools/testtool
|
||||||
test
|
test
|
||||||
.gdb_history
|
.gdb_history
|
@ -1,9 +1,4 @@
|
|||||||
|
|
||||||
EXE = nntpd
|
|
||||||
|
|
||||||
TOOL = nntpchan-tool
|
|
||||||
|
|
||||||
CXX = g++
|
|
||||||
REPO=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
REPO=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
SRC_PATH = $(REPO)/src
|
SRC_PATH = $(REPO)/src
|
||||||
|
|
||||||
@ -11,24 +6,40 @@ SOURCES := $(wildcard $(SRC_PATH)/*.cpp)
|
|||||||
HEADERS := $(wildcard $(SRC_PATH)/*.hpp)
|
HEADERS := $(wildcard $(SRC_PATH)/*.hpp)
|
||||||
OBJECTS := $(SOURCES:.cpp=.o)
|
OBJECTS := $(SOURCES:.cpp=.o)
|
||||||
|
|
||||||
|
TOOL_SRC_PATH := $(REPO)/tools
|
||||||
|
|
||||||
|
TOOL_SRC := $(wildcard $(TOOL_SRC_PATH)/*.cpp)
|
||||||
|
TOOLS := $(TOOL_SRC:.cpp=)
|
||||||
|
|
||||||
|
DAEMON_SRC = $(REPO)/daemon
|
||||||
|
|
||||||
PKGS := libuv libsodium
|
PKGS := libuv libsodium
|
||||||
|
|
||||||
LD_FLAGS := $(shell pkg-config --libs $(PKGS))
|
LD_FLAGS := $(shell pkg-config --libs $(PKGS))
|
||||||
INC_FLAGS := $(shell pkg-config --cflags $(PKGS)) -I $(REPO)/src
|
INC_FLAGS := $(shell pkg-config --cflags $(PKGS)) -I $(REPO)/src
|
||||||
CXXFLAGS := -std=c++11 -Wall -Wextra $(INC_FLAGS) -g
|
CXXFLAGS := -std=c++11 -Wall -Wextra $(INC_FLAGS)
|
||||||
|
|
||||||
LIB = libnntpchan.a
|
ifeq ($(DEBUG),1)
|
||||||
|
CXXFLAGS += -g
|
||||||
|
endif
|
||||||
|
|
||||||
all: $(EXE) $(TOOL)
|
LIB = $(REPO)/libnntpchan.a
|
||||||
|
|
||||||
|
EXE = $(REPO)/nntpd
|
||||||
|
|
||||||
|
|
||||||
|
all: $(EXE) $(TOOLS)
|
||||||
|
|
||||||
$(LIB): $(OBJECTS)
|
$(LIB): $(OBJECTS)
|
||||||
$(AR) -r $(LIB) $(OBJECTS)
|
$(AR) -r $(LIB) $(OBJECTS)
|
||||||
|
|
||||||
$(EXE): $(LIB)
|
$(EXE): $(LIB)
|
||||||
$(CXX) -o $(EXE) $(CXXFLAGS) nntpd.cpp $(LIB) $(LD_FLAGS)
|
$(CXX) $(CXXFLAGS) $(DAEMON_SRC)/main.cpp $(LIB) $(LD_FLAGS) -o $(EXE)
|
||||||
|
|
||||||
$(TOOL): $(LIB)
|
$(TOOL_SRC): $(LIB)
|
||||||
$(CXX) -o $(TOOL) $(CXXFLAGS) tool.cpp $(LIB) $(LD_FLAGS)
|
|
||||||
|
$(TOOLS): $(TOOL_SRC)
|
||||||
|
$(CXX) $(CXXFLAGS) $< $(LIB) $(LD_FLAGS) -o $@
|
||||||
|
|
||||||
build-test: $(LIB)
|
build-test: $(LIB)
|
||||||
$(CXX) -o test $(CXXFLAGS) test.cpp $(LIB) $(LD_FLAGS)
|
$(CXX) -o test $(CXXFLAGS) test.cpp $(LIB) $(LD_FLAGS)
|
||||||
@ -40,4 +51,4 @@ test: build-test
|
|||||||
$(CXX) $(CXXFLAGS) -c -o $@
|
$(CXX) $(CXXFLAGS) -c -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OBJECTS) $(LIB) $(EXE) $(TOOL) test
|
rm -f $(OBJECTS) $(LIB) $(EXE) $(TOOLS)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "ini.hpp"
|
#include "ini.hpp"
|
||||||
|
|
||||||
|
#include "crypto.hpp"
|
||||||
#include "storage.hpp"
|
#include "storage.hpp"
|
||||||
#include "nntp_server.hpp"
|
#include "nntp_server.hpp"
|
||||||
#include "event.hpp"
|
#include "event.hpp"
|
||||||
@ -15,6 +16,8 @@ int main(int argc, char * argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nntpchan::Crypto crypto();
|
||||||
|
|
||||||
nntpchan::Mainloop loop;
|
nntpchan::Mainloop loop;
|
||||||
|
|
||||||
nntpchan::NNTPServer nntp(loop);
|
nntpchan::NNTPServer nntp(loop);
|
@ -1,4 +1,6 @@
|
|||||||
#include "crypto.hpp"
|
#include "crypto.hpp"
|
||||||
|
#include <sodium.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
namespace nntpchan
|
namespace nntpchan
|
||||||
{
|
{
|
||||||
@ -6,4 +8,13 @@ namespace nntpchan
|
|||||||
{
|
{
|
||||||
crypto_hash(h.data(), d, l);
|
crypto_hash(h.data(), d, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Crypto::Crypto()
|
||||||
|
{
|
||||||
|
assert(sodium_init() == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Crypto::~Crypto()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,13 @@ namespace nntpchan
|
|||||||
typedef std::array<uint8_t, crypto_hash_BYTES> SHA512Digest;
|
typedef std::array<uint8_t, crypto_hash_BYTES> SHA512Digest;
|
||||||
|
|
||||||
void SHA512(const uint8_t * d, std::size_t l, SHA512Digest & h);
|
void SHA512(const uint8_t * d, std::size_t l, SHA512Digest & h);
|
||||||
|
|
||||||
|
/** global crypto initializer */
|
||||||
|
struct Crypto
|
||||||
|
{
|
||||||
|
Crypto();
|
||||||
|
~Crypto();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,10 +9,11 @@
|
|||||||
|
|
||||||
static void print_help(const std::string & exename)
|
static void print_help(const std::string & exename)
|
||||||
{
|
{
|
||||||
std::cout << "usage: " << exename << " [help|gencred|checkcred]" << std::endl;
|
std::cout << "usage: " << exename << " [help|gen|check]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_long_help() {
|
static void print_long_help()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,16 +59,16 @@ int main(int argc, char * argv[])
|
|||||||
print_long_help();
|
print_long_help();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (cmd == "gencred") {
|
if (cmd == "gen") {
|
||||||
if(argc == 4) {
|
if(argc == 4) {
|
||||||
gen_passwd(argv[2], argv[3]);
|
gen_passwd(argv[2], argv[3]);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "usage: " << argv[0] << " passwd username password" << std::endl;
|
std::cout << "usage: " << argv[0] << " gen username password" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(cmd == "checkcred" ) {
|
if(cmd == "check" ) {
|
||||||
std::string cred;
|
std::string cred;
|
||||||
std::cout << "credential: " ;
|
std::cout << "credential: " ;
|
||||||
if(!std::getline(std::cin, cred)) {
|
if(!std::getline(std::cin, cred)) {
|
13
contrib/backends/nntpchan-daemon/tools/testtool.cpp
Normal file
13
contrib/backends/nntpchan-daemon/tools/testtool.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "exec_frontend.hpp"
|
||||||
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(int , char * [])
|
||||||
|
{
|
||||||
|
nntpchan::Frontend * f = new nntpchan::ExecFrontend("./contrib/nntpchan.sh");
|
||||||
|
assert(f->AcceptsMessage("<test@server>"));
|
||||||
|
assert(f->AcceptsNewsgroup("overchan.test"));
|
||||||
|
std::cout << "all good" << std::endl;
|
||||||
|
}
|
Reference in New Issue
Block a user