-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from waitspring/dev
tcping
- Loading branch information
Showing
7 changed files
with
159 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AUTOMAKE_OPTIONS = foreign | ||
bin_PROGRAMS = tcping | ||
tcping_SOURCES = src/tcping.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
AC_PREREQ([2.69]) | ||
AC_INIT([morning-tavern], [1.0.1], [[email protected]]) | ||
AM_INIT_AUTOMAKE | ||
AC_CONFIG_SRCDIR([src/tcping.c]) | ||
AC_CONFIG_HEADERS([config.h]) | ||
AC_CONFIG_FILES([Makefile]) | ||
|
||
AC_PROG_CC | ||
|
||
AC_CHECK_HEADERS([arpa/inet.h netdb.h stdlib.h string.h sys/socket.h sys/time.h unistd.h]) | ||
|
||
AC_FUNC_ERROR_AT_LINE | ||
AC_CHECK_FUNCS([gettimeofday memset socket strrchr]) | ||
|
||
AC_OUTPUT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
Name: morning-tavern | ||
Version: 1.0.0 | ||
Release: 1%{?dist} | ||
Summary: A good repository for bash tools | ||
Name: morning-tavern | ||
Version: 1.0.1 | ||
Release: 1%{?dist} | ||
Summary: A good repository for bash tools | ||
|
||
Group: Development/Tools | ||
License: Apache 2.0 | ||
URL: https://github.com/waitspring/morning-tavern | ||
Source0: %{name}-%{version}.tar.gz | ||
Group: Development/Tools | ||
License: Apache 2.0 | ||
URL: https://github.com/waitspring/morning-tavern | ||
Source0: %{name}-%{version}.tar.gz | ||
|
||
Requires: bash | ||
BuildArch: noarch | ||
BuildRequires: gcc, make | ||
Requires: bash | ||
BuildArch: x86_64 | ||
|
||
%description | ||
A good repository for bash tools | ||
|
@@ -19,16 +20,26 @@ A good repository for bash tools | |
|
||
%build | ||
|
||
cd %{_builddir}/%{name}-%{version}/tcping | ||
%configure | ||
make CFLAGS=-std=c99 %{?_smp_mflags} | ||
|
||
%install | ||
mkdir -p %{buildroot}%{_bindir} | ||
install -m 0775 %{_builddir}/%{name}-%{version}/searchme/searchme %{buildroot}%{_bindir}/searchme | ||
install -m 0775 %{_builddir}/%{name}-%{version}/tcping/tcping %{buildroot}%{_bindir}/tcping | ||
mkdir -p %{buildroot}%{_sysconfdir} | ||
install -m 0664 %{_builddir}/%{name}-%{version}/searchme/searchme.conf %{buildroot}%{_sysconfdir}/searchme.conf | ||
|
||
%files | ||
%{_bindir}/searchme | ||
%{_sysconfdir}/searchme.conf | ||
%{_bindir}/tcping | ||
|
||
%changelog | ||
* Fri Dec 30 2022 waitspring <[email protected]> | ||
- Create the package for tcping command | ||
- Create the package for searchme command | ||
* Thu Dec 9 2021 waitspring <[email protected]> | ||
- Create the package for searchme command | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# RPM 仓库结构 | ||
|
||
`/srv/morning-tavern-1.0.1` 的目录结构如下: | ||
|
||
``` | ||
/srv/morning-tavern-1.0.1 | ||
│ | ||
├──── searchme | ||
│ ├──── searchme | ||
│ └──── searchme.conf | ||
└──── tcping | ||
├──── aclocal.m4 | ||
├──── config.h.in | ||
├──── configure | ||
├──── configure.ac | ||
├──── Makefile.am | ||
├──── Makefile.in | ||
└──── src | ||
├──── tcping | ||
└──── tcping.c | ||
``` | ||
|
||
`/root/rpmbuild` 的目录结构如下: | ||
|
||
``` | ||
/root/rpmbuild | ||
│ | ||
├──── BUILD | ||
├──── BUILDROOT | ||
├──── RPMS | ||
├──── SOURCES | ||
│ └──── morning-tavern-1.0.1.tar.gz | ||
├──── SPECS | ||
│ └──── morning-tavern.spec | ||
└──── SRPMS | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Tcping | ||
|
||
### 一、使用说明 | ||
|
||
**Tcping** 小工具在 Github 开源社区有很多作者实现过, 但从使用体验的层面看始终存在各种小瑕疵 | ||
|
||
**Tcping** 小工具由本人重构之后, 具备下述特点: | ||
|
||
+ 允许在 `Shell` 脚本内配合 `IFS` 命令与循环结构使用 | ||
+ 允许使用静默工作模式 | ||
+ 根据执行结果的不同有不同的退出码: | ||
* TCP 连接全部建立成功使用数值 0 作为退出码 | ||
* TCP 连接部分建立成功使用数值 1 作为退出码 | ||
* TCP 连接全部建立失败使用数值 2 作为退出码 | ||
|
||
### 二、使用方法 | ||
|
||
**Tcping** 小工具的安装方法说明如下: | ||
|
||
```bash | ||
$ gcc --std=c99 -o /usr/bin/tcping /path/to/tcping.c | ||
$ chmod a+x /usr/bin/tcping | ||
``` | ||
|
||
**Tcping** 小工具的使用方法说明如下: | ||
|
||
```bash | ||
$ tcping [option...] socket | ||
|
||
-c, --count=TIMES # 配置命令发起 TIMES 次 TCP 连接, 默认值为 86400 (保持长 TCPING) | ||
-i, --interval=NUM # 配置两次连接中的停顿时间为 NUM 秒钟, 默认值为 1 秒钟 | ||
-q, --quiet # 开启静默执行模式, 命令屏蔽正常输出 | ||
-h, --help # 列出命令的帮助信息 | ||
-v, --version # 列出命令的版本信息 | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters