diff --git a/.github/workflows/checkstyle.yml b/.github/workflows/checkstyle.yml index 7594d69..a1c30c3 100644 --- a/.github/workflows/checkstyle.yml +++ b/.github/workflows/checkstyle.yml @@ -1,21 +1,16 @@ +# Copyright 2024 shoothzj # -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. name: checkstyle on: diff --git a/.github/workflows/line_lint.yml b/.github/workflows/line_lint.yml index e2d2f89..519b5f9 100644 --- a/.github/workflows/line_lint.yml +++ b/.github/workflows/line_lint.yml @@ -1,21 +1,16 @@ +# Copyright 2024 shoothzj # -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. name: line lint on: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d492f90..b77fc50 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,21 +1,16 @@ +# Copyright 2024 shoothzj # -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. name: Release diff --git a/.github/workflows/spotbugs.yml b/.github/workflows/spotbugs.yml index 1d13a9e..e1ec83c 100644 --- a/.github/workflows/spotbugs.yml +++ b/.github/workflows/spotbugs.yml @@ -1,21 +1,16 @@ +# Copyright 2024 shoothzj # -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. +# http://www.apache.org/licenses/LICENSE-2.0 # +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. name: spot bugs on: diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 1979ef7..0000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,44 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name: unit tests -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - unit-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Maven Central Repository - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'temurin' - - name: unit tests - run: mvn -B clean test - - uses: codecov/codecov-action@v2 - with: - files: ./java-tool/target/site/jacoco/jacoco.xml,./sdk-codec-bk/target/site/jacoco/jacoco.xml - flags: unittests diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..ff89ed1 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,39 @@ +# Copyright 2024 shoothzj +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: unit tests +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Maven Central Repository + uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'temurin' + - name: unit tests + run: mvn -B clean test + - uses: codecov/codecov-action@v2 + with: + files: ./java-tool/target/site/jacoco/jacoco.xml,./sdk-codec-bk/target/site/jacoco/jacoco.xml + flags: unittests diff --git a/ci/spotbugs/exclude.xml b/ci/spotbugs/exclude.xml index 28f6735..a3cdc3c 100644 --- a/ci/spotbugs/exclude.xml +++ b/ci/spotbugs/exclude.xml @@ -34,4 +34,8 @@ + + + + diff --git a/example/src/main/java/io/github/protocol/sms/server/example/CmppServerExample.java b/example/src/main/java/io/github/protocol/sms/server/example/CmppServerExample.java new file mode 100644 index 0000000..85cbb88 --- /dev/null +++ b/example/src/main/java/io/github/protocol/sms/server/example/CmppServerExample.java @@ -0,0 +1,13 @@ +package io.github.protocol.sms.server.example; + +import io.github.protocol.sms.cmpp.server.CmppConfig; +import io.github.protocol.sms.cmpp.server.CmppServer; + +public class CmppServerExample { + public static void main(String[] args) throws Exception { + CmppConfig config = new CmppConfig(); + config = config.port(PortConst.CMPP_DEFAULT_PORT); + CmppServer cmppServer = new CmppServer(config); + cmppServer.start(); + } +} diff --git a/example/src/main/java/io/github/protocol/sms/server/example/CngpServerExample.java b/example/src/main/java/io/github/protocol/sms/server/example/CngpServerExample.java new file mode 100644 index 0000000..630e83b --- /dev/null +++ b/example/src/main/java/io/github/protocol/sms/server/example/CngpServerExample.java @@ -0,0 +1,13 @@ +package io.github.protocol.sms.server.example; + +import io.github.protocol.sms.cngp.server.CngpConfig; +import io.github.protocol.sms.cngp.server.CngpServer; + +public class CngpServerExample { + public static void main(String[] args) throws Exception { + CngpConfig config = new CngpConfig(); + config = config.port(PortConst.CNGP_DEFAULT_PORT); + CngpServer cngpServer = new CngpServer(config); + cngpServer.start(); + } +} diff --git a/example/src/main/java/io/github/protocol/sms/server/example/SgipServerExample.java b/example/src/main/java/io/github/protocol/sms/server/example/SgipServerExample.java new file mode 100644 index 0000000..4fe0c64 --- /dev/null +++ b/example/src/main/java/io/github/protocol/sms/server/example/SgipServerExample.java @@ -0,0 +1,13 @@ +package io.github.protocol.sms.server.example; + +import io.github.protocol.sms.sgip.server.SgipConfig; +import io.github.protocol.sms.sgip.server.SgipServer; + +public class SgipServerExample { + public static void main(String[] args) throws Exception { + SgipConfig config = new SgipConfig(); + config = config.port(PortConst.SGIP_DEFAULT_PORT); + SgipServer sgipServer = new SgipServer(config); + sgipServer.start(); + } +} diff --git a/example/src/main/java/io/github/protocol/sms/server/example/SmgpServerExample.java b/example/src/main/java/io/github/protocol/sms/server/example/SmgpServerExample.java new file mode 100644 index 0000000..9492769 --- /dev/null +++ b/example/src/main/java/io/github/protocol/sms/server/example/SmgpServerExample.java @@ -0,0 +1,13 @@ +package io.github.protocol.sms.server.example; + +import io.github.protocol.sms.smgp.server.SmgpConfig; +import io.github.protocol.sms.smgp.server.SmgpServer; + +public class SmgpServerExample { + public static void main(String[] args) throws Exception { + SmgpConfig config = new SmgpConfig(); + config = config.port(PortConst.SMGP_DEFAULT_PORT); + SmgpServer smgpServer = new SmgpServer(config); + smgpServer.start(); + } +} diff --git a/pom.xml b/pom.xml index 2749188..a683a84 100644 --- a/pom.xml +++ b/pom.xml @@ -24,19 +24,21 @@ UTF-8 src/main/java - 5.9.2 + 5.10.2 2.20.0 - 5.2.0 - 4.1.90.Final + 1.18.30 + 5.11.0 + 4.1.107.Final + 10.14.0 2.0.7 - 0.0.11 + 0.0.12 - 3.10.1 - 3.2.1 - 1.18.26 - 10.11.0 - 4.7.3.0 - 3.1.0 + 1.18.20.0 + 3.11.0 + 3.3.1 + 3.6.0 + 3.2.1 + 4.8.3.1 @@ -99,7 +101,7 @@ org.apache.maven.plugins maven-compiler-plugin - ${compiler-plugin.version} + ${maven-compiler-plugin.version} ${maven.compiler.source} ${maven.compiler.target} @@ -108,12 +110,12 @@ org.apache.maven.plugins maven-surefire-plugin - ${surefire-plugin.version} + ${maven-surefire-plugin.version} org.apache.maven.plugins maven-checkstyle-plugin - ${checkstyle-plugin.version} + ${maven-checkstyle-plugin.version} com.puppycrawl.tools @@ -167,7 +169,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + ${maven-javadoc-plugin.version} ${src.dir} all,-missing @@ -293,12 +295,12 @@ org.projectlombok lombok-maven-plugin - 1.18.20.0 + ${lombok-maven-plugin.version} org.projectlombok lombok - 1.18.24 + ${lombok.version} diff --git a/sms-server-cmpp/src/main/java/io/github/protocol/sms/cmpp/server/CmppServer.java b/sms-server-cmpp/src/main/java/io/github/protocol/sms/cmpp/server/CmppServer.java index 2426f4b..3ebdd01 100644 --- a/sms-server-cmpp/src/main/java/io/github/protocol/sms/cmpp/server/CmppServer.java +++ b/sms-server-cmpp/src/main/java/io/github/protocol/sms/cmpp/server/CmppServer.java @@ -1,8 +1,13 @@ package io.github.protocol.sms.cmpp.server; import io.github.protocol.codec.cmpp.CmppConnect; +import io.github.protocol.codec.cmpp.CmppConnectBody; +import io.github.protocol.codec.cmpp.CmppConnectResp; +import io.github.protocol.codec.cmpp.CmppConnectRespBody; +import io.github.protocol.codec.cmpp.CmppConst; import io.github.protocol.codec.cmpp.CmppDecoder; import io.github.protocol.codec.cmpp.CmppEncoder; +import io.github.protocol.codec.cmpp.CmppHeader; import io.github.protocol.codec.cmpp.CmppMessage; import io.github.protocol.codec.cmpp.CmppSubmit; import io.github.protocol.sms.server.util.BoundAtomicInt; @@ -22,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; import java.util.Optional; @ChannelHandler.Sharable @@ -105,7 +111,12 @@ public void channelRead(ChannelHandlerContext ctx, Object message) { } } - private void processConnect(ChannelHandlerContext ctx, CmppConnect message) { + private void processConnect(ChannelHandlerContext ctx, CmppConnect msg) { + CmppHeader header = new CmppHeader(CmppConst.CONNECT_RESP_ID, msg.header().sequenceId()); + CmppConnectBody body = msg.body(); + String authenticator = new String(body.authenticatorSource(), StandardCharsets.UTF_8); + CmppConnectRespBody respBody = new CmppConnectRespBody(0, authenticator, (byte) 0); + ctx.writeAndFlush(new CmppConnectResp(header, respBody)); } private void processSubmit(ChannelHandlerContext ctx, CmppSubmit message) { diff --git a/sms-server-cngp/src/main/java/io/github/protocol/sms/cngp/server/CngpServer.java b/sms-server-cngp/src/main/java/io/github/protocol/sms/cngp/server/CngpServer.java index fa3223a..ab52a52 100644 --- a/sms-server-cngp/src/main/java/io/github/protocol/sms/cngp/server/CngpServer.java +++ b/sms-server-cngp/src/main/java/io/github/protocol/sms/cngp/server/CngpServer.java @@ -1,9 +1,14 @@ package io.github.protocol.sms.cngp.server; +import io.github.protocol.codec.cngp.CngpConst; import io.github.protocol.codec.cngp.CngpDecoder; import io.github.protocol.codec.cngp.CngpEncoder; import io.github.protocol.codec.cngp.CngpExit; +import io.github.protocol.codec.cngp.CngpHeader; import io.github.protocol.codec.cngp.CngpLogin; +import io.github.protocol.codec.cngp.CngpLoginBody; +import io.github.protocol.codec.cngp.CngpLoginResp; +import io.github.protocol.codec.cngp.CngpLoginRespBody; import io.github.protocol.codec.cngp.CngpMessage; import io.github.protocol.codec.cngp.CngpSubmit; import io.github.protocol.sms.server.util.BoundAtomicInt; @@ -109,6 +114,10 @@ public void channelRead(ChannelHandlerContext ctx, Object message) { } private void processLogin(ChannelHandlerContext ctx, CngpLogin msg) { + CngpHeader header = new CngpHeader(CngpConst.LOGIN_RESP_ID, 0, msg.header().sequenceId()); + CngpLoginBody body = msg.body(); + CngpLoginRespBody respBody = new CngpLoginRespBody(body.authenticatorClient(), (byte) 0); + ctx.writeAndFlush(new CngpLoginResp(header, respBody)); } private void processSubmit(ChannelHandlerContext ctx, CngpSubmit msg) { diff --git a/sms-server-sgip/src/main/java/io/github/protocol/sms/sgip/server/SgipServer.java b/sms-server-sgip/src/main/java/io/github/protocol/sms/sgip/server/SgipServer.java index 692ce94..2ebdcc1 100644 --- a/sms-server-sgip/src/main/java/io/github/protocol/sms/sgip/server/SgipServer.java +++ b/sms-server-sgip/src/main/java/io/github/protocol/sms/sgip/server/SgipServer.java @@ -1,8 +1,12 @@ package io.github.protocol.sms.sgip.server; import io.github.protocol.codec.sgip.SgipBind; +import io.github.protocol.codec.sgip.SgipBindResp; +import io.github.protocol.codec.sgip.SgipBindRespBody; +import io.github.protocol.codec.sgip.SgipConst; import io.github.protocol.codec.sgip.SgipDecoder; import io.github.protocol.codec.sgip.SgipEncoder; +import io.github.protocol.codec.sgip.SgipHeader; import io.github.protocol.codec.sgip.SgipMessage; import io.github.protocol.codec.sgip.SgipReport; import io.github.protocol.codec.sgip.SgipSubmit; @@ -118,6 +122,9 @@ public void channelRead(ChannelHandlerContext ctx, Object message) { } private void processBind(ChannelHandlerContext ctx, SgipBind msg) { + SgipHeader header = new SgipHeader(SgipConst.BIND_RESP_ID, msg.header().sequenceNumber()); + SgipBindRespBody respBody = new SgipBindRespBody((byte) 0, ""); + ctx.writeAndFlush(new SgipBindResp(header, respBody)); } private void processUnbind(ChannelHandlerContext ctx, SgipUnbind msg) { diff --git a/sms-server-smgp/src/main/java/io/github/protocol/sms/smgp/server/SmgpServer.java b/sms-server-smgp/src/main/java/io/github/protocol/sms/smgp/server/SmgpServer.java index 19d2bbd..406f00b 100644 --- a/sms-server-smgp/src/main/java/io/github/protocol/sms/smgp/server/SmgpServer.java +++ b/sms-server-smgp/src/main/java/io/github/protocol/sms/smgp/server/SmgpServer.java @@ -1,8 +1,13 @@ package io.github.protocol.sms.smgp.server; +import io.github.protocol.codec.smgp.SmgpConst; import io.github.protocol.codec.smgp.SmgpDecoder; import io.github.protocol.codec.smgp.SmgpEncoder; +import io.github.protocol.codec.smgp.SmgpHeader; import io.github.protocol.codec.smgp.SmgpLogin; +import io.github.protocol.codec.smgp.SmgpLoginBody; +import io.github.protocol.codec.smgp.SmgpLoginResp; +import io.github.protocol.codec.smgp.SmgpLoginRespBody; import io.github.protocol.codec.smgp.SmgpMessage; import io.github.protocol.codec.smgp.SmgpSubmit; import io.github.protocol.sms.server.util.BoundAtomicInt; @@ -106,6 +111,10 @@ public void channelRead(ChannelHandlerContext ctx, Object message) { } private void processLogin(ChannelHandlerContext ctx, SmgpLogin msg) { + SmgpHeader header = new SmgpHeader(SmgpConst.LOGIN_RESP_ID, msg.header().sequenceID()); + SmgpLoginBody body = msg.body(); + SmgpLoginRespBody respBody = new SmgpLoginRespBody(0, body.authenticatorClient(), (byte) 0); + ctx.writeAndFlush(new SmgpLoginResp(header, respBody)); } private void processSubmit(ChannelHandlerContext ctx, SmgpSubmit msg) {