From b5444a2d9c481019180f5677452245bc5618f21f Mon Sep 17 00:00:00 2001 From: KOROyo123 <1121910079@qq.com> Date: Wed, 5 Jun 2024 16:14:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=9B=B4=E6=96=B0=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AAlistener=E7=9A=84=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=A8=A1=E5=BC=8F=E5=BC=80=E5=85=B3=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=85=81=E8=AE=B8=E8=AE=BE=E5=A4=87=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=B8=8D=E5=B8=A6=E5=9B=9E=E8=BD=A6=E6=8D=A2=E8=A1=8C=EF=BC=88?= =?UTF-8?q?\r\n)=E7=9A=84=E8=AF=B7=E6=B1=82=E6=9D=A5=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=EF=BC=8C=E4=BB=A5=E5=85=BC=E5=AE=B9=E6=9F=90?= =?UTF-8?q?=E4=BA=9B=E9=87=87=E7=94=A8=E7=AC=AC=E4=B8=89=E6=96=B9=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=BF=9B=E8=A1=8CNtrip=E9=AA=8C=E8=AF=81=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=EF=BC=88=E8=BF=99=E4=BA=9B=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=B8=8D=E6=94=AF=E6=8C=81=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=B8=A6=E5=9B=9E=E8=BD=A6=E6=8D=A2=E8=A1=8C=E7=9A=84=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E8=BF=87=E4=BA=8E=E8=BE=A3=E9=B8=A1=EF=BC=8C?= =?UTF-8?q?=E5=B7=A5=E4=B8=9A=E5=BA=9F=E6=96=99=E4=BA=86=E5=B1=9E=E4=BA=8E?= =?UTF-8?q?=E6=98=AFT=5FT=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conf/Service_Setting.yml.in | 3 ++- .../include/Connector/ntrip_compat_listener.h | 1 + .../src/Connector/ntrip_compat_listener.cpp | 20 ++++++++++++++++--- app/Koro_Caster_Service/src/main.cpp | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app/Koro_Caster_Service/conf/Service_Setting.yml.in b/app/Koro_Caster_Service/conf/Service_Setting.yml.in index 21253b52..7fff97e1 100644 --- a/app/Koro_Caster_Service/conf/Service_Setting.yml.in +++ b/app/Koro_Caster_Service/conf/Service_Setting.yml.in @@ -1,10 +1,11 @@ # Koro_Caster_Service 主体配置文件 -# 适用版本:1.1.3.1或更高 +# 适用版本:1.1.3.3或更高 # 监听端口设置 Ntrip_Listener_Setting: Listen_Port: 4202 #监听的端口 Connect_Timeout: 30 #连接无响应超时时间(建立了TCP连接但是并不发送验证信息)(/秒)(≤0 :关闭) + Header_No_CRLF: true #兼容模式,允许用户仅发送Header头登录,且不必发送回车换行,但是同时由于没有回车换行,也不能携带除挂载点之外的任何信息 #基站相关设置 Server_Setting: diff --git a/app/Koro_Caster_Service/include/Connector/ntrip_compat_listener.h b/app/Koro_Caster_Service/include/Connector/ntrip_compat_listener.h index 375ceeca..739962f6 100755 --- a/app/Koro_Caster_Service/include/Connector/ntrip_compat_listener.h +++ b/app/Koro_Caster_Service/include/Connector/ntrip_compat_listener.h @@ -47,6 +47,7 @@ class ntrip_compat_listener private: int _listen_port; int _connect_timeout = 0; + bool _enable_no_CRLF = true; event_base *_base; evconnlistener *_listener; diff --git a/app/Koro_Caster_Service/src/Connector/ntrip_compat_listener.cpp b/app/Koro_Caster_Service/src/Connector/ntrip_compat_listener.cpp index 96cac6fb..187e69cd 100755 --- a/app/Koro_Caster_Service/src/Connector/ntrip_compat_listener.cpp +++ b/app/Koro_Caster_Service/src/Connector/ntrip_compat_listener.cpp @@ -12,6 +12,7 @@ ntrip_compat_listener::ntrip_compat_listener(json conf, event_base *base, std::u { _listen_port = conf["Port"]; _connect_timeout = conf["Timeout"]; + _enable_no_CRLF=conf["Enable_No_CRLF"]; _base = base; _connect_map = connect_map; @@ -135,6 +136,19 @@ void ntrip_compat_listener::Ntrip_Decode_Request_cb(bufferevent *bev, void *ctx) size_t header_len = 0; char *header = evbuffer_readln(evbuf, &header_len, EVBUFFER_EOL_CRLF); + if (header == NULL && svr->_enable_no_CRLF) // 允许不带回车换行的请求登录 + { + auto len = evbuffer_get_length(evbuf); + if (len < 255) + { + spdlog::warn("[{}:{}]: header dont'have CRLF, but Set [Header_No_CRLF], accept this header", __class__, __func__); + header = new char[len + 1]; + header[len] = '\0'; + header_len = len; + evbuffer_remove(evbuf, header, header_len); + } + } + try { if (header == NULL | header_len > 255 | header_len < 9) // HTTP请求最短长度也要15 "GET / HTTP/1.0" NTRIP1.0请求最短长度为9 "SOURCE 1" @@ -532,11 +546,11 @@ std::string ntrip_compat_listener::extract_path(std::string path) mount = path.substr(1, x - 1); search = path.substr(x + 1); } - if(!check_mount_is_valid(mount)) + if (!check_mount_is_valid(mount)) { throw std::invalid_argument("MountPoint Name invalid"); } - + return mount; } @@ -595,7 +609,7 @@ int ntrip_compat_listener::erase_and_free_bev(bufferevent *bev, std::string Conn bool ntrip_compat_listener::check_mount_is_valid(const std::string &str) { - if(str.empty()) //针对获取源列表的情况 + if (str.empty()) // 针对获取源列表的情况 { return true; } diff --git a/app/Koro_Caster_Service/src/main.cpp b/app/Koro_Caster_Service/src/main.cpp index b11743bb..41eb088b 100755 --- a/app/Koro_Caster_Service/src/main.cpp +++ b/app/Koro_Caster_Service/src/main.cpp @@ -60,6 +60,7 @@ json load_Caster_Conf(const char *conf_directory) auto Ntrip_Listener_Setting = Conf["Ntrip_Listener_Setting"]; conf["Ntrip_Listener"]["Port"] = Ntrip_Listener_Setting["Listen_Port"].as(); conf["Ntrip_Listener"]["Timeout"] = Ntrip_Listener_Setting["Connect_Timeout"].as(); + conf["Ntrip_Listener"]["Enable_No_CRLF"]=Ntrip_Listener_Setting["Header_No_CRLF"].as(); auto Server_Setting = Conf["Server_Setting"]; conf["Server_Setting"]["Timeout"] = Server_Setting["Connect_Timeout"].as();