1 unstable release
0.1.0 | Aug 2, 2022 |
---|
#3 in #fox
535KB
301 lines
Steel Plate
Project Steel Plate for Arctic Fox (or 雪狐桑)
Volunteer
You can help improve the UI design by pulling request.
Additionally, authorized media materials will also be highly appreciated.
Tested Browsers
- Safari (has a known bug)
- Google Chrome
Installation
AWS Lambda
Build
Mac OS
(Tested on Apple Silicon ONLY)
- Install Rust develop environment
- Add target
x86_64-unknown-linux-musl
with command below:
$ rustup target add x86_64-unknown-linux-musl
- Install ross-compilation toolchain
$ brew install filosottile/musl-cross/musl-cross
- Navigate into project root, then run
$ mkdir .cargo
$ echo '[target.x86_64-unknown-linux-musl]
linker = "x86_64-linux-musl-gcc"' > .cargo/config
- Add command alias for
x86_64-linux-musl-gcc
$ ln -s `where x86_64-linux-musl-gcc` /usr/local/bin/musl-gcc
- Cross compile
$ cargo build --release --target x86_64-unknown-linux-musl
- Pack as zip file
$ zip -j rust.zip ./target/x86_64-unknown-linux-musl/release/bootstrap
Linux amd64
!!! TO BE TESTED !!!
- Install Rust develop environment
- Navigate into project root
- Compile
$ cargo build --release
- Pack as zip file
$ zip -j rust.zip ./target/release/bootstrap
Lambda Prepare
- Click
Create function
on Lambda Functions page - Choose
Author from scratch
- Enter your function name
- Set
Runtime
toProvide your own bootstrap on Amazon Linux 2
- Set
Architecture
tox86_64
- Click
Create function
to finish create - Go into the function you created, click
Upload from
under cardCode source
- Choose
.zip file
- Upload
rust.zip
packed in the previous step, and clickSave
- Wait until it finishes
DynamoDB Prepare
- Click
Create table
on DynamoDB Tables page - Enter your
Table name
- Set
Partition key
tokey
with typeString
- Set
Table settings
according to your needs - Click
Create table
to finish create - Click
Explore items
on sidebar - Choose the
Table name
you set before - Click
Create item
- Under
Add new attribute
, chooseNumber
- Set Value to
total
where Attribute name showskey
- Change
NewValue
tovalue
and set its Value to0
- Click
Create item
to finish
Edit roles
- Go to IAM and open Roles
- Choose the role bound to the lambda function you created before
- Click
Attach policies
underAdd permissions
- Either create your own policy (safer, more complex), or use
AmazonDynamoDBFullAccess
provides by AWS (more dangerous, but easier) - Click
Attach policies
to finish role edition Example custom policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "0",
"Effect": "Allow",
"Action": [
"dynamodb:PutItem",
"dynamodb:GetItem",
"dynamodb:UpdateItem"
],
"Resource": "arn:aws:dynamodb:xxxxxx:xxxxxxx:table/xxxxxx"
},
{
"Sid": "1",
"Effect": "Allow",
"Action": "dynamodb:ListTables",
"Resource": "*"
}
]
}
Api Gateway Setup
- Create a
HTTP API
- Set
Integrations
to your lambda function - Under
Configure routes
, set Method toANY
, Resource path to/{proxy+}
and Integration target to your lambda function - Set others as default or edit them to your preference
- Open the URL showed in
Invoke URL
, and you can finally enjoy the 100% pure steel plate of Arctic Fox
Standalone
!!! Standalone will store total clicks in the server memory and ONLY in the memory !!!
However, by setting env STEEL_PLATE_COUNT_BASE
, you can set the base clicks count number
- Install Rust development environment
- Navigate into project root
- Compile with command below:
$ cargo build --release
- Run:
$ ./target/release/steel-plate
- Enjoy the high-purity steel plate of Arctic Fox at
http://127.0.0.1:8082/
Known Bugs
- Unable to play the audio after quick clicks on Safari
External Links
- Arctic Fox (or 雪狐桑): Bilibili UID:477792
LICENSE
MIT LICENSE
2022 Richard Chen
Dependencies
~35–52MB
~1M SLoC