릴리스 노트

Ubuntu Server 16.04.1 LTS 64비트 또는 Ubuntu Server 18.04.1 LTS 64비트.

ubuntu@VM-69-2-ubuntu:~$ export SECRET_ID=AKxxxxxxxxxxxxxxxxxxxxxxx; export SECRET_KEY=xxxxxxxxxxxxxxxxxxxxx;export APPID=125xxxxxxx;export ANTI_LEECH_KEY=xxxx;git clone https://github.com/tencentyun/vod-server-demo.git ~/vod-server-demo; bash ~/vod-server-demo/installer/anti_leech_sign_scf_en.sh
[2020-06-04 15:57:10]Npm 검사 시작.[2020-06-04 15:57:18]Npm 설치 성공.[2020-06-04 15:57:18]ServerLess 설치 시작.[2020-06-04 15:57:19]ServerLess 설치 성공.[2020-06-04 15:57:20]VOD Key 링크 도용 방지 서명 배포 서비스 구성 시작.[2020-06-04 15:57:30]VOD Key 링크 도용 방지 서명 배포 서비스 구성 완료.[2020-06-04 15:57:32]서비스 주소: https://service-xxxxxxxx-125xxxxxxx.gz.apigw.tencentcs.com/release/anti_leech_sign
https://service-xxxxxxxx-125xxxxxxx.gz.apigw.tencentcs.com/release/anti_leech_sign)를 복사합니다.[2020-04-25 17:18:44]경고: Key 링크 도용 방지 서명 배포 서비스 테스트에 실패했습니다.

curl 명령을 실행하여 해당 URL에 직접 액세스를 시도해 보십시오. Key 링크 도용 방지 규칙에 부합하지 않을 경우, 서버가 액세스를 거부하며 HTTP 반환 코드는 403입니다(다음과 같이 테스트 시 명령의 URL을 실제 URL로 바꿉니다).ubuntu@VM-69-2-ubuntu:~$ curl -I "http://125xxxxxxx.vod2.myqcloud.com/f888c998vodcq125xxxxxxx/c849148f528xxxxxxxxxxxxxxxx/xxxxxxxxxx.mp4"HTTP/1.1 403 ForbiddenServer: NWS_VPConnection: keep-aliveDate: Thu, 04 Jun 2020 08:27:54 GMTContent-Type: text/plainContent-Length: 14
curl 명령을 실행하여 4단계에서 배포한 서비스를 요청하고 링크 도용 방지 서명이 있는 URL을 가져옵니다(-d는 POST 방식을 사용하여 요청을 시작하는 것을 의미하며, 비디오 URL 매개변수를 가지고 있습니다).ubuntu@VM-69-2-ubuntu:~$ curl -d 'http://125xxxxxxx.vod2.myqcloud.com/f888c998vodcq125xxxxxxx/c849148f528xxxxxxxxxxxxxxxx/xxxxxxxxxx.mp4' https://service-xxxxxxxx-125xxxxxxx.gz.apigw.tencentcs.com/release/anti_leech_sign; echohttp://125xxxxxxx.vod2.myqcloud.com/f888c998vodcq125xxxxxxx/c849148f528xxxxxxxxxxxxxxxx/xxxxxxxxxx.mp4?t=5ed8b8d2&exper=0&rlimit=0&us=455041&sign=fe6394007c2e7aef39fc70a02e897f69
ubuntu@VM-69-2-ubuntu:~$ curl -I "http://125xxxxxxx.vod2.myqcloud.com/f888c998vodcq125xxxxxxx/c849148f528xxxxxxxxxxxxxxxx/xxxxxxxxxx.mp4?t=5ed8b8d2&exper=0&rlimit=0&us=455041&sign=fe6394007c2e7aef39fc70a02e897f69"HTTP/1.1 200 OKServer: tencent-cosConnection: keep-aliveDate: Thu, 04 Jun 2020 08:37:17 GMTLast-Modified: Fri, 22 May 2020 15:06:15 GMTContent-Type: video/mp4Content-Length: 232952632Accept-Ranges: bytesETag: "1da6be3a0d1da5edae4ff0b1feff02cf-223"x-cos-hash-crc64ecma: 16209801220610226954x-cos-request-id: NWVkOGIyYmVfZDUyMzYyNjRfYWMwMF85YjkyNzA=X-Daa-Tunnel: hop_count=4X-NWS-LOG-UUID: b404f43e-3c86-4c54-8a78-fb78e4e85cf2 add71e19fb08c6d9dbe1b21a2fb157bfAccess-Control-Allow-Credentials: trueAccess-Control-Allow-Headers: Origin,No-Cache,X-Requested-With,If-Modified-Since,Pragma,Last-Modified,Cache-Control,Expires,Content-Type,X_Requested_With,RangeAccess-Control-Allow-Methods: GET,POST,OPTIONSAccess-Control-Allow-Origin: *
서비스 | SCF 이름 | 인터페이스 형식 | 요청 내용 | 반환 내용 |
Key 링크 도용 방지 서명 배포 | anti_leech_sign | HTTP POST | 비디오 원본 URL | 링크 도용 방지 서명 URL |
Main_handler()는 엔트리 함수입니다.parse_conf_file ()을 호출하고, config.json 파일에서 설정 정보를 읽어옵니다. 설정 항목에 대한 설명은 다음과 같습니다(자세한 매개변수는 Key 링크 도용 방지 서명 매개변수를 참고하십시오).필드 | 데이터 유형 | 기능 |
key | String | Key 링크 도용 방지 키 |
t | Integer | 서명 유효 시간으로, 단위는 초입니다. 요청 처리 시, 해당 매개변수와 SCF 서버의 현재 시간을 더하면 링크 도용 방지 매개변수의 t가 됩니다. |
exper | Integer | 미리보기 시간 |
rlimit | Integer | 서명에 액세스 할 수 있는 최대 클라이언트 IP 수 |
Dir 매개변수를 분석하여, 로컬에서 t와 us 매개변수를 생성하고, 구성 파일에서 exper와 rlimit 매개변수를 읽어옵니다.original_url = event["body"]parse_result = urlparse(original_url)directory = path.split(parse_result.path)[0] + '/'# 서명 매개변수timestamp = int(time.time())rand = random.randint(0, 999999)sign_para = {"t": hex(timestamp + configuration['t'])[2:],"exper": configuration['exper'],"rlimit": configuration['rlimit'],"us": rand}
Generate_sign()를 호출하여 링크 도용 방지 서명을 계산합니다. 자세한 알고리즘은 Key 링크 도용 방지 서명을 참고하십시오.sign_para["sign"] = signaturequery_string = urlencode(sign_para)new_parse_result = parse_result._replace(query=query_string)signed_url = urlunparse(new_parse_result)
return {"isBase64Encoded": False,"statusCode": 200,"headers": {"Content-Type": "text/plain; charset=utf-8","Access-Control-Allow-Origin": "*","Access-Control-Allow-Methods": "POST,OPTIONS"},"body": signed_url}
피드백