-
Notifications
You must be signed in to change notification settings - Fork 2
[IDEA] proxy mode
yongbin edited this page Sep 13, 2010
·
4 revisions
(절대로 어제 차이고 혼자 떡볶이 먹었다고 열폭하는거 아님)
- JEEN사마 1번째 아이디어 구현 (+aero님 comment) – DL2 가 amazon으로 보내는 request 를 가로체서 amazon 의 서비스 지역 ( ca, de, fr, jp, uk, or us ) 이면 그대로 amazon 으로 보내고 그 외 지역일 경우 plugin 형태로 지역별(barcode or ISBN의 prefix 별) handler 를 plugin 형태로 호출해서 처리한 후에 amazon 에서 받는 response 와 동일한 포멧으로 DL2 가 결과를 받을수 있도록 하는 구현
- 지역별 handler는 로컬에서 request 를 해서 받아오는 방식 or JEEN 사마 집서버로 다 보내고 유료화 하는 방식
- hijacking : 사용자의 /etc/hosts 파일에 ‘webservices.amazon.com’ 도메인 참조주소를 server 로 변경 (127.0.0.1 or blah)
- proxy : request 의 ISBN 을 찾아내서 정상 amazon request 일 경우 amazon 으로 던짐
GET /onca/xml?AWSAccessKeyId=1XKMQ76GH235KSFB1M02&AssociateTag=deliciousmons-20&ItemId=0596004788&ItemPage=1&Operation=ItemLookup&ResponseGroup=Small%2CItemAttributes%2CTracks%2CImages%2CBrowseNodes%2COfferSummary%2CEditorialReview%2CReviews&ReviewSort=-HelpfulVotes&Service=AWSECommerceService&Timestamp=2009-10-09T16%3A08%3A44Z&Version=2009-07-01&Signature=OHkd1KoFRzVnJ0xoPbiR3v0Tga0NntVUQMTMi%2BLbyck%3D HTTP/1.1 Host: webservices.amazon.com User-Agent: Library/2.2 CFNetwork/454.4 Darwin/10.0.0 (i386) (MacBook1%2C1) Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate Cookie: __utma=194891197.1070002100.1255101853.1255101853.1255101853.1; __utmz=194891197.1255101853.1.1.utmccn=(organic)|utmcsr=google|utmctr=amazonaws|utmcmd=organic; session-id=189-8177889-5110206; session-id-time=1255676400l; ubid-main=182-3284414-3605320 Connection: keep-alive
- handler : localhost or web server 쪽으로 보내고 응답만들어서 response
request
/onca/xml?AWSAccessKeyId=19E64160MR69H1K90QG2
ItemId=0201360683
ItemPage=1
Operation=ItemLookup
ResponseGroup=Large
Service=AWSECommerceService
Sort=salesrank
Timestamp=2009-10-09T16%3A51%3A46Z
Version=2009-07-01
Signature=AW%2B0G6M4ZU5oyYdFXr9P4Bcmev9rxVJ3tmY2Qlw0Ouw%3D
========================================
/onca/xml?AWSAccessKeyId=1XKMQ76GH235KSFB1M02
AssociateTag=deliciousmons-20
ItemId=0596004788
ItemPage=1
Operation=ItemLookup
ResponseGroup=Small%2CItemAttributes%2CTracks%2CImages%2CBrowseNodes%2COfferSummary%2CEditorialReview%2CReviews
ReviewSort=-HelpfulVotes
Service=AWSECommerceService
Timestamp=2009-10-09T16%3A08%3A44Z
Version=2009-07-01
Signature=OHkd1KoFRzVnJ0xoPbiR3v0Tga0NntVUQMTMi%2BLbyck%3D
========================================
/onca/xml?AWSAccessKeyId=19E64160MR69H1K90QG2
ItemId=0201360683
ItemPage=1
Operation=ItemLookup
ResponseGroup=Large
Service=AWSECommerceService
Sort=salesrank
Timestamp=2009-10-09T16%3A51%3A46Z
Version=2009-07-01
Signature=AW%2B0G6M4ZU5oyYdFXr9P4Bcmev9rxVJ3tmY2Qlw0Ouw%3D
========================================
/onca/xml?AWSAccessKeyId=1XKMQ76GH235KSFB1M02
AssociateTag=deliciousmons-20
ItemId=0596004788
ItemPage=1
Operation=ItemLookup
ResponseGroup=Small%2CItemAttributes%2CTracks%2CImages%2CBrowseNodes%2COfferSummary%2CEditorialReview%2CReviews
ReviewSort=-HelpfulVotes
Service=AWSECommerceService
Timestamp=2009-10-09T16%3A08%3A44Z
Version=2009-07-01
Signature=OHkd1KoFRzVnJ0xoPbiR3v0Tga0NntVUQMTMi%2BLbyck%3D
========================================
echo "GET /onca/xml?AWSAccessKeyId=1XKMQ76GH235KSFB1M02&AssociateTag=deliciousmons-20&ItemId=0596004788&ItemPage=1&Operation=ItemLookup&ResponseGroup=Small%2CItemAttributes%2CTracks%2CImages%2CBrowseNodes%2COfferSummary%2CEditorialReview%2CReviews&ReviewSort=-HelpfulVotes&Service=AWSECommerceService&Timestamp=2009-10-09T15%3A28%3A01Z&Version=2009-07-01&Signature=qWRz5avB2GrqBN7sZPopjDdtXFjPEWjNc7sLGeiAfOU%3D" \
| nc webservices.amazon.com 80 \
| tidy -i -xml
1차 Proxy 완성후 확인결과 DL2 에서는 스캔이 발생하면 위 리퀘스트 이외에 아래와 같은 리퀘스트를 한번 더 보낸다.
========================================
http://webservices.amazon.com/onca/xml?AWSAccessKeyId=1XKMQ76GH235KSFB1M02
AssociateTag=deliciousmons-20
ItemId=0596004788
ItemPage=1
Operation=SimilarityLookup
ResponseGroup=Small%2CItemAttributes%2CImages
Service=AWSECommerceService
Timestamp=2009-10-11T11%3A52%3A41Z
Version=2009-07-01
Signature=jdJ7%2FfQRQt8kWfMcw53L%2BG%2FOpSeR10t29JyNXzuBaIQ%3D
========================================
=> WebService::Aladin 에 그런거 없으므로 무시하기로
- AWS.TimestampExceedsTimeToLive : (done) request 에 현재시간+timezone 반영해서 900 아마존 서버와 900 이내차이가 나도록 처리하면 됨
- AWS.InvalidParameterValue : (done)
- AWS.InvalidSignature : (done)
세가지 전부 해결방법이 같은데 AWS에서 request 를 처리할때 AWS timestamp, AWS계정 토큰, AWS secrect key 를 이용해서 request signature 를 만들어낸다 Net::Amazon 에서 구현한 코드를 그대로 따와서 해결함
SEE : http://docs.amazonwebservices.com/AWSECommerceService/2009-03-31/DG/Query_QueryAuth.html
- installer
- install
- /etc/hosts 에 항목추가
- local proxy 서버 up
- => 일원화 서버를 고려하는 쪽으로…
- uninstall
- /etc/hosts 항목 삭제
- 파일 삭제
- 근데 mac 에서는 특별한 uninstall process 가 없는데 어떻함?
- => 그런 곳에 신경쓸 시간에 떡볶이! // 없으면 안합니다.
- install