APIban-mysql 클라이언트
9083 단어 nodemysqlapibanjavascript
Apiban-mysql
간단한 apiban-mysql 프로젝트를 소개합니다. APIBan REST API에서 SIP 공격자 IP를 가져와 MySQL 데이터베이스 테이블에 저장합니다.
프로젝트 다운로드
git clone https://github.com/ajamous/apiban-mysql.git
디렉토리 변경
cd apiban-mysql/
종속성 설치
npm install
mysql db에 필요한 테이블 생성
CREATE TABLE "last_fetched_id" (
"id" varchar(32) NOT NULL DEFAULT '',
PRIMARY KEY ("id")
);
CREATE TABLE "apiban_banned_ips" (
"ip" varchar(15) NOT NULL DEFAULT '',
PRIMARY KEY ("ip")
);
INSERT INTO last_fetched_id(id) values('');
APIBan API key 및 DB Credentials 입력
vi sync.js
/* validate environment */
const APIBAN_API_KEY = "XXXXXXXXXXXXXXXXX"
const APIBAN_MYSQL_SERVER = "replace_with_mysql_ip_or_host"
const APIBAN_MYSQL_PORT = 3306
const APIBAN_MYSQL_DATABASE = "replace_with_db_name"
const APIBAN_MYSQL_USER = "replace_with_mysql_user"
const APIBAN_MYSQL_PASSWORD = "replace_with_mysql_password"
스크립트 실행
node sync.js
샘플 출력
$ node sync.js
getting ips list...
starting from ID: undefined
fetched 250 ips, next ID 1663924065
fetched 250 ips, next ID 1663954967
fetched 250 ips, next ID 1663970136
fetched 250 ips, next ID 1663991432
fetched 250 ips, next ID 1664018643
fetched 250 ips, next ID 1664039285
fetched 250 ips, next ID 1664058709
fetched 250 ips, next ID 1664082297
fetched 250 ips, next ID 1664111965
fetched 250 ips, next ID 1664130848
fetched 250 ips, next ID 1664160433
fetched 250 ips, next ID 1664198153
fetched 250 ips, next ID 1664229896
fetched 250 ips, next ID 1664259993
fetched 250 ips, next ID 1664287578
fetched 250 ips, next ID 1664321167
fetched 250 ips, next ID 1664330768
fetched 250 ips, next ID 1664351231
fetched 250 ips, next ID 1664373761
fetched 250 ips, next ID 1664386920
saving ips list into DB...
done.
더 이상 추가할 IP가 없을 때
$ node sync.js
getting ips list...
starting from ID: 1664386920
no new banned IPs since last sync, exiting...
MySQL DB 테이블에서 업데이트를 확인하십시오.
도움이 되었기를 바랍니다.
당신은 또한 좋아할 수 있습니다
git clone https://github.com/ajamous/apiban-mysql.git
cd apiban-mysql/
npm install
CREATE TABLE "last_fetched_id" (
"id" varchar(32) NOT NULL DEFAULT '',
PRIMARY KEY ("id")
);
CREATE TABLE "apiban_banned_ips" (
"ip" varchar(15) NOT NULL DEFAULT '',
PRIMARY KEY ("ip")
);
INSERT INTO last_fetched_id(id) values('');
vi sync.js
/* validate environment */
const APIBAN_API_KEY = "XXXXXXXXXXXXXXXXX"
const APIBAN_MYSQL_SERVER = "replace_with_mysql_ip_or_host"
const APIBAN_MYSQL_PORT = 3306
const APIBAN_MYSQL_DATABASE = "replace_with_db_name"
const APIBAN_MYSQL_USER = "replace_with_mysql_user"
const APIBAN_MYSQL_PASSWORD = "replace_with_mysql_password"
node sync.js
$ node sync.js
getting ips list...
starting from ID: undefined
fetched 250 ips, next ID 1663924065
fetched 250 ips, next ID 1663954967
fetched 250 ips, next ID 1663970136
fetched 250 ips, next ID 1663991432
fetched 250 ips, next ID 1664018643
fetched 250 ips, next ID 1664039285
fetched 250 ips, next ID 1664058709
fetched 250 ips, next ID 1664082297
fetched 250 ips, next ID 1664111965
fetched 250 ips, next ID 1664130848
fetched 250 ips, next ID 1664160433
fetched 250 ips, next ID 1664198153
fetched 250 ips, next ID 1664229896
fetched 250 ips, next ID 1664259993
fetched 250 ips, next ID 1664287578
fetched 250 ips, next ID 1664321167
fetched 250 ips, next ID 1664330768
fetched 250 ips, next ID 1664351231
fetched 250 ips, next ID 1664373761
fetched 250 ips, next ID 1664386920
saving ips list into DB...
done.
$ node sync.js
getting ips list...
starting from ID: 1664386920
no new banned IPs since last sync, exiting...
Reference
이 문제에 관하여(APIban-mysql 클라이언트), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/ameedjamous/apiban-mysql-client-4n3c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)