forked from ff522/dm-ticket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Classmate Lin
committed
May 27, 2023
0 parents
commit aa0e5a8
Showing
22 changed files
with
1,294 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[source.crates-io] | ||
# To use sparse index, change 'rsproxy' to 'rsproxy-sparse' | ||
replace-with = 'rsproxy' | ||
|
||
[source.rsproxy] | ||
registry = "https://rsproxy.cn/crates.io-index" | ||
[source.rsproxy-sparse] | ||
registry = "sparse+https://rsproxy.cn/index/" | ||
|
||
[registries.rsproxy] | ||
index = "https://rsproxy.cn/crates.io-index" | ||
|
||
[net] | ||
git-fetch-with-cli = true |
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,53 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
tags: [ 'v*.*.*' ] | ||
|
||
env: | ||
REGISTRY: docker.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
|
||
- name: Sign the published Docker image | ||
if: ${{ github.event_name != 'pull_request' }} | ||
env: | ||
COSIGN_EXPERIMENTAL: "true" | ||
# This step uses the identity token to provision an ephemeral certificate | ||
# against the sigstore community Fulcio instance. | ||
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} |
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,20 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
.history/ | ||
|
||
config/config.yml | ||
|
||
.idea/ |
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,21 @@ | ||
[package] | ||
name = "dm-ticket" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
serde = {version = "1.0.148", features = ["derive"]} | ||
serde_json = {version = "1.0.89", default-features = false, features = ["alloc"]} | ||
serde_yaml = "0.9.21" | ||
schemars = "0.8.12" | ||
tokio = { version = "1.21.2", default-features = false, features = ["macros", "rt-multi-thread", "signal", "time"] } | ||
reqwest = {version="0.11.12", default-features=false, features = ["json", "rustls-tls", "cookies", "multipart"]} | ||
anyhow = {version="1.0.66"} | ||
log={version="0.4.17"} | ||
pretty_env_logger="0.4.0" | ||
md5 = {version="0.7.0"} | ||
futures = {version="0.3.28"} | ||
chrono = {version="0.4.24", features = ["unstable-locales"] } | ||
async-channel={version = "1.8"} |
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 @@ | ||
# 编译 | ||
FROM --platform=$TARGETPLATFORM rust:1.68-alpine3.17 as builder | ||
|
||
WORKDIR /usr/src | ||
|
||
RUN USER=root cargo new dm-ticket | ||
|
||
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g" /etc/apk/repositories; | ||
|
||
RUN apk add musl-dev openssl openssl-dev pkgconfig upx git | ||
|
||
COPY Cargo.toml Cargo.lock /usr/src/dm-ticket/ | ||
|
||
COPY .cargo /usr/src/dm-ticket/.cargo | ||
|
||
WORKDIR /usr/src/dm-ticket | ||
|
||
RUN cargo build --release --verbose | ||
|
||
COPY src /usr/src/dm-ticket/src/ | ||
|
||
RUN RUST_BACKTRACE=1 cargo build --release && upx /usr/src/dm-ticket/target/release/dm-ticket | ||
|
||
FROM --platform=$TARGETPLATFORM alpine:3.17 as runtime | ||
|
||
ENV TZ=Asia/Shanghai | ||
|
||
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g" /etc/apk/repositories \ | ||
&& apk update \ | ||
&& apk add --no-cache vim tzdata \ | ||
&& echo "${TZ}" > /etc/timezone \ | ||
&& ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \ | ||
&& rm -rf /var/cache/apk/* | ||
|
||
WORKDIR /src/ | ||
|
||
COPY --from=builder /usr/src/dm-ticket/target/release/dm-ticket /usr/bin/dm-ticket | ||
|
||
CMD ["/usr/sbin/crond", "-f", "-d", "0"] |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Classmate Lin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,31 @@ | ||
# dm-ticket | ||
## 简介 | ||
|
||
大麦网自动购票, 支持docker一键部署。 | ||
|
||
|
||
## 特别声明 | ||
- 本项目内所有资源文件,禁止任何公众号、自媒体进行任何形式的转载、发布。 | ||
- 编写本项目主要目的为学习和研究Rust,无法保证项目内容的合法性、准确性、完整性和有效性。 | ||
- 本项目涉及的数据由使用的个人或组织自行填写,本项目不对数据内容负责,包括但不限于数据的真实性、准确性、合法性。使用本项目所造成的一切后果,与本项目的所有贡献者无关,由使用的个人或组织完全承担。 | ||
- 本项目中涉及的第三方硬件、软件等,与本项目没有任何直接或间接的关系。本项目仅对部署和使用过程进行客观描述,不代表支持使用任何第三方硬件、软件。使用任何第三方硬件、软件,所造成的一切后果由使用的个人或组织承担,与本项目无关。 | ||
- 本项目中所有内容只供学习和研究使用,不得将本项目中任何内容用于违反国家/地区/组织等的法律法规或相关规定的其他用途。 | ||
- 所有基于本项目源代码,进行的任何修改,为其他个人或组织的自发行为,与本项目没有任何直接或间接的关系,所造成的一切后果亦与本项目无关。 | ||
- 所有直接或间接使用本项目的个人和组织,应24小时内完成学习和研究,并及时删除本项目中的所有内容。如对本项目的功能有需求,应自行开发相关功能。 | ||
- 本项目保留随时对免责声明进行补充或更改的权利,直接或间接使用本项目内容的个人或组织,视为接受本项目的特别声明。 | ||
|
||
## 使用说明 | ||
|
||
- 下载docker-compose配置文件: `wget https://github.com/ClassmateLin/dm-ticket/releases/download/v0.1.0/dm-ticket.zip` | ||
- 解压zip: `unzip dm-ticket.zip && cd dm-ticket` | ||
- 运行容器: `docker-compose up -d` | ||
- 修改配置: `vim config/config.yaml`, 配置项在config/config.yaml中有详细注释。 | ||
- 运行脚本: `docker exec -it dm-ticket dm-ticket` | ||
 | ||
|
||
|
||
## 赞赏 | ||
|
||
如果我的项目对你有帮助: | ||
|
||
<img src="./images/pay.jpeg" width="256px;" > |
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,23 @@ | ||
accounts: | ||
# .damai.cn中的cookie字符串 | ||
- cookie: "cna=XD3FHNoADAMCAdzxKqCz0c5s; xxx=ssss;xxx=ssss;" | ||
remark: 账号1 | ||
# 抢票轮训间隔, 单位毫秒 | ||
interval: 30 | ||
|
||
# 最早提前多少毫秒发包。 开抢剩余时间戳 = 开始售票的时间戳 - 当前时间戳。 当开抢剩余时间戳时间小于 submit_time时, 开始发送数据包。 | ||
earliest_submit_time: 15 | ||
|
||
ticket: | ||
# 需要抢购的门票ID, 门票详情页URL中的itemId.如:https://m.damai.cn/damai/detail/item.html?utm=&itemId=710947802955 | ||
id: "719062769469" | ||
# 需要抢购的门票数量 | ||
num: 2 | ||
# 需要抢购的场次序号. | ||
sessions: 2 | ||
# 需要抢购的票档序号 | ||
grade: 2 | ||
|
||
|
||
|
||
|
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 @@ | ||
version: "3" | ||
|
||
networks: | ||
dm_network: | ||
driver: bridge | ||
# ipam: | ||
# driver: default | ||
# config: | ||
# - subnet: 172.20.0.0/16 | ||
# gateway: 172.20.0.1 | ||
|
||
|
||
services: | ||
|
||
dm-ticket: | ||
image: classmatelin/dm-ticket:latest | ||
container_name: dm-ticket | ||
restart: always | ||
privileged: true | ||
volumes: | ||
- "./config:/src/config" | ||
networks: | ||
- dm_network | ||
depends_on: | ||
- token-server | ||
environment: | ||
RUST_LOG: "INFO" | ||
TOKEN_SERVER_URL: "http://token-server:8080" | ||
|
||
token-server: | ||
image: classmatelin/alitoken-server:latest | ||
restart: always | ||
container_name: token-server | ||
networks: | ||
- dm_network | ||
environment: | ||
RUST_LOG: "info" | ||
ports: | ||
- "8080:8080" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.