Skip to content

Commit

Permalink
use json config file
Browse files Browse the repository at this point in the history
  • Loading branch information
tisyang committed Mar 23, 2020
1 parent 84f95cf commit 6be3e76
Show file tree
Hide file tree
Showing 56 changed files with 4,454 additions and 64,660 deletions.
11 changes: 7 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[submodule "ulog"]
path = ulog
url = https://github.com/tisyang/ulog.git
[submodule "libev"]
path = libev
url = https://github.com/opensource-mirrors/libev.git
[submodule "wsocket"]
path = wsocket
url = https://github.com/lazytinker/wsocket.git
[submodule "logh"]
path = logh
url = https://github.com/lazytinker/log.h.git
url = https://github.com/tisyang/wsocket.git
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ project(ntripcaster)
set(CMAKE_C_STANDARD 99)

add_subdirectory(wsocket)
add_subdirectory(ulog)
add_subdirectory(cJSON)

IF(WIN32)
add_executable(${PROJECT_NAME} ntripcaster.c evwrap.c)
target_link_libraries(${PROJECT_NAME}
wsocket
ulog
cJSON
)
ELSE()
add_executable(${PROJECT_NAME} ntripcaster.c)
target_link_libraries(${PROJECT_NAME}
wsocket
ulog
cJSON
ev
)
ENDIF()
Expand Down
57 changes: 47 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# ntripcaster
Ntrip broadcaster written in c and libev.
Ntrip broadcaster written in c and libev, support windows and linux.

For now, it can now transmit data between ntrip servers and ntrip clients, with source table and authorization support.

## Note
这是一个简易实现的 ntripcaster 服务器程序,也是一些其他基于 Ntrip 协议开发实现的程序的蓝本源码,包括千寻位置等 CORS 服务的差分分发代理程序(暂不开源)。后续将基于此仓库开发,逐步实现对于 Ntrip 各类功能程序的简化和抽象,使得不同场景可以基于简单的配置或编码,来实现期望的功能。
基于 libev 库实现的 C 语言版本 Ntripcaster 程序,支持 windows 和 linux。

## Build
目前可以支持 ntrip client 和 ntrip server 交换数据、动态源列表,以及密码验证(client 和 source 都支持)。

## Build 构建
Need cmake and git and libev.

Windows only test on MinGW/MinGW-w64 toolchains.

需要 cmake 和 git 工具,以及系统安装了 libev (仅linux下需要,Debian/Ubuntu 可以使用 `apt-get install libev-dev` 安装)。

Windows 编译仅在 MinGW/MinGW-w64 测试过。


```shell
git clone https://github.com/lazytinker/ntripcaster.git
git clone https://github.com/tisyang/ntripcaster.git
cd ntripcaster
git submodule update --init

Expand All @@ -20,13 +28,42 @@ cmake ..
make
```

## Pre-build binaries
https://github.com/lazytinker/ntripcaster_bin
## Pre-build binaries 预编译二进制文件
https://github.com/tisyang/ntripcaster_bin

## Usage 使用

## Usage
程序使用 json 配置文件,默认配置文件名为 `ntripcaster.json` ,但可以通过命令行参数传入配置文件名: `ntripcaster.exe xxx.json`

Run it, it will listen on port 2101.
配置文件项说明:

+ `listen_addr`: 字符串,程序将使用的 caster 服务地址,默认为 "0.0.0.0".
+ `listen_port`: 整数,程序将使用的 caster 服务端口,默认为 2101.
+ `max_client`: 整数,可接入的 ntrip client 客户端最大数量,0表示无限制。默认为0.
+ `max_source`: 整数,可接入的 ntrip source 客户端最大数量,0表示无限制。默认为0.
+ `max_pending`: 整数,允许的无标识客户端(即非client也非source)最大数量,0表示无限制。默认为10.
+ `tokens_client`: object,每一项的名称表示一个 client 密码对,以冒号分隔的用户名和密码。值表示的可以访问的挂载点名称。挂载点支持 `*` 符号,表示可以访问任何挂载点。
+ `tokens_source`: object, 每一项的名称表示一个 source 密码。值表示可以写入数据的挂载点名称。挂载点支持 `*` 符号,表示可以访问任何挂载点。

配置文件示例:

```json
{
"listen_addr":"0.0.0.0",
"listen_port": 2101,
"max_client": 0,
"max_source": 0,
"max_pending": 10,
"tokens_client": {
"test:test": "*"
},
"tokens_source": {
"test": "*"
}
}

```

## Contact Me
## Contact Me 联系

lazy.tinker#outlook.com
Loading

0 comments on commit 6be3e76

Please sign in to comment.