作者: Leic

  • Learning rtmpdump Through Examples

    http://pclosmag.com/html/Issues/201104/page19.html

    Learning rtmpdump Through Examples

    by pstranger

    Today, technology goes forward and we get some new possibilities. TV broadcasting doesn’t lose time and goes forward too. Today, you can watch online TV and watch TV programs on demand. But what if you want to record them? Don’t worry – some programs and live broadcasting (not all yet) can be recorded.

    If you are not so young, then you can remember the VCR (video cassette recorder) era. You could turn on your video recorder, push the “Record” button, stop it after some time and after rewinding the tape you could play a recorded program on your TV. So what does the computer era offer?

    Some theory

    Today, TV broadcasting via internet goes in many popular stream formats and protocols.

    You have certainly heard about such streaming formats:

    • flash video streams (Adobe Flash Player): FLV, MP4, F4V
    • Windows media streams (Windows Media Player): WMV, ASF, ASX and others.

    There are also various streaming protocols. Examples of streaming protocols:

    • flash video: HTTP, RTMP, RTMPE
    • Windows media video: HTTP, RTSP, MMS and others.

    Let’s take a look at services which are broadcasting in the RTMP protocol. What is it? Wikipedia says: “Real Time Messaging Protocol (RTMP) was initially a proprietary protocol developed by Macromedia for streaming audio, video and data over the Internet, between a Flash player and a server. Macromedia is now owned by Adobe, which has released the specification of the protocol for public use.”

    So if your favorite online service (TV or video archive) uses the RTMP protocol you have a good chance of being able to save its video stream as a file on your local drive. There is an excellent utility for recording streams broadcasting TV and video on demand. This utility is called “rtmpdump.” What is it? “rtmpdump” is a console toolkit for RTMP streams. Does the word “console” mean advantage or disadvantage in this case? I think it is big advantage for such a tool. Its operating principle is simple: you input the name of a command with some options, which include the address of the video server, and get a desirable file containing the recorded TV program. You will see no graphical input on the screen, nor other useless information. It just connects to the server, consuming only the network traffic containing the video, and records it to your hard disk. If you know about the powerful “wget” utility, then you can imagine what it is like.

    Prepare

    It’s time to start. To have “rtmpdump” in your operational system, you should install the package having the same name from the repository. This package goes with another utility, which is called “rtmpsuck.” This tool can also record video stream, but we will use it as auxiliary tool to find options for “rtmpdump.”

    In order to use “rtmpsuck,” we need some preparation. “rtmpsuck” is a local RTMP proxy server which passes traffic into the internet through itself, detecting the flowing RTMP protocol and it’s parameters. “rtmpsuck” goes with no parameters. So if you run “rtmpsuck” you can only see:

    RTMP proxy server … … Streaming on rtmp://0.0.0.0:1935
    

    What that says is that the server is running and listening on port 1935. It’s necessary to notice that port 1935 is a default port of RTMP servers. But in this case, “rtmpsuck” is useless. Why? Because to make it work, you need to redirect RTMP traffic to a proxy server, which in turn will help us to know the connection parameters to the media server. To do this, you need to run the following command as a “root”:

    iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT
    

    The meaning of this command is to add a new rule in the table controlling your network traffic in order to redirect outbound TCP traffic flowing to the default RTMP external server port (1935) to a local RTMP proxy server, except traffic which belongs to root. So, if you now open a page in you browser to watch a media stream, your traffic will flow via the proxy server, and “rtmpsuck” will provide you information which can be used in “rtmpdump.” After getting all the information, you can close “rtmpsuck” (Ctrl+C) and must remove the “iptabels” rule which you added before:

    iptables -t nat -D OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT
    
      1. Example: Online IP TV broadcasting (“Russia Today”)

    Step 1 Run as a root in terminal:

    iptables -t nat -A OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT
    

    Step 2 Run as a root in terminal:

    rtmpsuck
    

    Step 3 As an ordinary user, open in Firefox this address: http://rt.com/on-air/rt-america-air/

    Step 4 Switch to root’s terminal. You should see something like the following:

    app: live flashVer: LNX 10,1,82,76
    swfUrl: http://rt.com/s/swf/player5.4.viral.swf
    tcUrl: rtmp://rt.fms.visionip.tv/live
    pageUrl: http://rt.com/on-air/rt-america-air/
    Playpath: RT_US_3
    

    Break the command after a while (Ctrl+C).

    Depending on your connection quality, you can get different meanings of the option “Playpath”.

    You can change the options of video quality by using the following entries after the command Playpath:

    RT_US_3 – high
    RT_US_2 – medium
    RT_US_1 – low
    

    Step 5 Run the command in root terminal:

    iptables -t nat -D OUTPUT -p tcp --dport 1935 -m owner \! --uid-owner root -j REDIRECT
    

    Step 6 Run the command in terminal as an ordinary user:

    rtmpdump -r rtmp://rt.fms.visionip.tv/live \
    -a live \
    -y RT_US_3 \ -W http://rt.com/s/swf/player5.4.viral.swf \
    -p http://rt.com/on-air/rt-america-air/ \
    -f "LNX 10,1,82,76" \
    -o ~/rt.flv \
    -V \
    -B 600
    

    After 10 minutes, you will get the video file “rt.flv” in your home directory which you can play in your favorite media player.

    You can know what these parameters mean if you run the manual of command “rtmpdump”:

    man rtmpdump
    

    Option -V is just verbose, turn it off if your test recording is passed.

    Exercise 1: If you live in Europe or Asia (or if it is just convenient to you), you can try to get the parameters for main broadcasting. Firefox address is http://rt.com/on-air/

      1. Example: Online IP TV broadcasting (“Bloomberg”)

    Repeat steps 1 through 5 for address http://www.bloomberg.com/tv/

    Step 6 Run the following command in terminal as an ordinary user:

    rtmpdump -r rtmpt://cp87869.live.edgefcs.net/live \
    -a live \
    -y us_300@21006 \
    -W http://player.ooyala.com/static/cacheable/29d28e187072cf05af879e362d57b42d/player_v2.swf \
    -p http://www.bloomberg.com/tv/ \
    -f "LNX 10,1,82,76" \
    -o ~/bloomberg.flv \
    -V \
    -B 600 \
    --live
    

    Here we added the option “— live” to make utility work right.

      1. Example: TV streaming LIVE (“Euronews”)

    The address of streaming broadcasting is: http://www.euronews.net/news/streaming-live/

    “rtmpsuck” gives us the next:

    app: rtpeuronewslive
    flashVer: LNX 10,1,82,76
    swfUrl: http://www.euronews.net/media/player_live_1_7.swf
    tcUrl: rtmp://178.32.100.43:1935/rtpeuronewslive
    pageUrl: http://www.euronews.net/news/streaming-live/
    Playpath: eng_euronews-flash-750.sdp
    

    so our command will be:

    rtmpdump -r rtmp://178.32.100.43:1935/rtpeuronewslive \
    -a rtpeuronewslive \
    -y eng_euronews-flash-750.sdp \
    -W http://www.euronews.net/media/player_live_1_7.swf \
    -p http://www.euronews.net/news/streaming-live \
    -f "LNX 10,1,82,76" \
    -o ~/euronews.flv \
    -B 600
    
      1. Example: Video on demand (“Deutsche Welle”)

    There are many good programs you can find on this page: http://www.dw-world.de/dw/0,,4756,00.html

    But if you try above technique, disappointment will wait for you. The reason for this is the video server is broadcasting on a different port. If you look into the source code of “rtmpsuck” you can see that default port of RTMP server (1935) is hard-coded, and that is why “rtmpsuck” is not a helper to us in this case.

    The tool that will help us is called “tcpdump.” It is a console network sniffer. The nice feature of this tool is that it can show only printable symbols contained in network packets, which is handy for capturing web pages and this kind of stuff. If this tool is not yet installed on your system, you should do it now. The next utility is “grep” which helps to print lines matching a pattern which can be set.

    Let’s get one of the excellent programs about lifestyle Europe, which is called “Euromaxx.” We assume that RTMP proxy server is not running and redirection traffic is turned off.

    Step 1 Run as a “root” in terminal next set of commands:

    tcpdump -ieth0 -nn -A |grep -e"rtmp" -e"connect" -e"play">/euromaxx.txt
    

    It means that strings which included patterns (rtmp, connect or play) containing in network traffic and flowing trough network interface (eth0 in my case) will be recorded in file “euromaxx.txt,” which will be located in root directory (“/”).

    Step 2 As an ordinary user, open in Firefox page: http://mediacenter.dw-world.de/english/video/#!/93184/euromaxx/Program=7555 and start to play the video. Wait a moment for the video to start to play, click the “pause” button on the built-in player, and click the “Update page” button on Firefox. Repeat this action 4 times.

    Step 3 Go to root terminal and break running commands (Ctrl+C).

    Step 4 Open the file “euromaxx.txt” in text editor and find piece of text:

    connect.?..........app..
    a4337/dwwod1/..flashVer...LNX 10,1,82,76..swfUrl..;http://mediacenter.dw-world.de/player/flash/media.player.swf..tcUrl..*rtmpt://tvone.fcod.llnwd.net/a4337/dwwod1/..fpad....capabilities.@m........audioCodecs.@.........videoCodecs..@o....... videoFunction.?.........pageUrl..Khttp://mediacenter.dw-world.de/english/video/#!/93184/euromaxx/Program=7555..object.Encoding.@......... ................closeStream.....................H.....P.....play............;mp4:dwtv_video/flv/eme/emagen100311-euromaxx01ep_sd_avc.mp4
    

    Now you can easily determinate options for “rtmpdump”.

    Step 5 Run command in terminal as ordinary user:

    rtmpdump -r rtmpt://tvone.fcod.llnwd.net/a4337/dwwod1/ \
    -a a4337/dwwod1/ \
    -y mp4:dwtv_video/flv/eme/emagen100311-euromaxx01ep_sd_avc.mp4 \
    -f "LNX 10,1,82,76" \
    -W http://mediacenter.dw-world.de/player/flash/media.player.swf \
    -p http://mediacenter.dw-world.de/english/video/#!/93184/euromaxx/Program=7555 \
    -o ~/euromaxx.flv
    

    After a while you will find the recorded program in your home directory.

    The pitfall of this technique is that you can meet dots in an inappropriate place in the string. The reason for this is the fact that the text string, which should be continuous, is situated in two network packets and “tcpdump” changes unprintable symbols to dots. So, if something goes wrong, then place the key -V into you “rtmpdump” command and look at the debug messages. If “rtmpdump” can’t even connect to the server, then the reason in this case is rather a wrong URL.

    Finishing stroke

    There is a natural desire to record some program on a schedule (placing recording script for example in “cron”). If you will use the same file name of a recorded video program, then you will rewrite the previous one. In order to avoid this, it is very convenient to use the file name which contains the name of the broadcasting server, including the date and time of the recording. The next script shows the usage of this trick for our first TV broadcasting example:

    #!/bin/bash
    BASENAME="rt"
    FILENAME="$BASENAME"_`date +%Y-%m-%d_%H%M%S`.flv
    rtmpdump -r rtmp://rt.fms.visionip.tv/live \
    -y RT_US_3 \
    -o ~/$FILENAME \
    -B 1200
    

    Exercise 2: Write a script for the scheduler in order to record a program which was yesterday in the last video on demand example using this hint:

    YESTERDAY=$(date -d yesterday +"%d%m%y")
    

    The answers will appear elsewhere in this issue of magazine. Also, you can find more information about streaming media recording on this site http://all-streaming-media.com/

  • Chambers and Partners)

    http://www.chambersandpartners.com/

     

    Chambers Global Top 30

    http://www.chambersandpartners.com/global-comparisontable

    28 Morgan, Lewis & Bockius LLP Global Firm (USA) with 29 offices in 11 countries Global-wide, Latin America-wide, Middle East-wide, Belgium, Kazakhstan, Russia, Singapore, United Arab Emirates, USA Capital Markets: Structured Finance, Securitisation & Derivatives, Commercial Contracts, Employment, Immigration Citi, Credit Suisse, Morgan Stanley, Barclays Automobiles & Parts, Insurance, Media, Pharmaceuticals & Life Sciences, Telecommunications, Travel & Leisure

     

     

     

     

    Arnold & Porter Kaye Scholer LLP

    This Firm’s Rankings in Chambers Global 2017

    USA:   Intellectual Property: Patent (Band 4)

     

     

    【钱伯斯是什么】

    所谓“2015钱伯斯排名”,是指著名法律评级机构钱伯斯(Chambers and Partners)在其发布的《2015亚太法律指南》(2015Asia-Pacific Guide)中评出的2015年亚太地区律所排名。

    钱伯斯,是一家总部位于英国伦敦的法律评级机构,自1969年开始向世界发布不同国家的律所与律师排名,其通过严谨的调研和评价体系,评选出各个法律领域的全球知名律师事务所和顶尖级律师,成为全球客户寻求高端法律服务最值得信赖的权威参考之一,被广泛视为业界的基准。钱伯斯的中国榜单与研究也已走过九个年头。

    钱伯斯有句注明的slogan为“No one can‘buy their way in’”,可谓是其榜单的最高目标与最佳写照。

    【钱伯斯排名中的排名类型】

    钱伯斯的主体榜单分为6档,Band 1 –Band 6。Band 1为最优,这不代表排在较低档次的律所或律师不好,能够上榜都已是颇具实力的表现,只是较低档次的入选者在某方面与较高排名者仍有些差距。

    此外,钱伯斯不是每个榜单都是会排满6个档次,只有在法律高度发达和竞争激烈领域才会有6档或者接近6档的榜单出现,比如像Asia Guide中Australia的Dispute Resolution争端解决领域(5个band)或是UK Guide中London Tax的领域(6个band)。对于有些法律市场容量非常小的领域,出于宁缺毋滥的原则,甚至会出现无一律所上榜的情况,这也不足为奇。

    钱伯斯在律师排名方面除了上述以数字等级排列的榜单外,还有一些特殊的排名,其中包括“Senior Statesmen业界元老 ”、“Star Individuals业界明星”、“Eminent Practitioners业界贤达”、 “Up-and-Coming Individuals潜质律师”、“Associatesto Watch后起之秀”等。这其中前几类主要针对资深合伙人而设,比如“Star Individuals业界明星”通常指业内最为出色的明星律师。 “Eminent Practitioners业界贤达”通常指那些经验丰富、但更多将精力转向客户维系和团队管理的杰出律师。除了资深律师外钱伯斯对青年律师也一直很关注。“Up-and-Coming Individuals潜质律师”、“Associatesto Watch后起之秀”正是两类最值得年轻律师朋友们注意的个人排名,分别针对的是合伙人和associate 级别的新晋律师,这两个分类是许多上榜律师都曾经历过的阶段,可以说它们是登上钱伯斯榜单的第一步。

    【钱伯斯排名是如何产生的】

    钱伯斯的研究团队全部常驻伦敦。研究员主要通过公开市场领域的信息搜集、申报材料研究、律师以及客户采访(以电话或者邮件形式)等手段对目标范围内的律师和律所进行研究。

    个人排名 | 研究员会根据律师的法律知识、经验、专长、效率、勤奋程度以及客户服务水平等几个维度来考察律师个人的水平。以上各个维度的优劣判别主要通过与活跃的市场人士(主要是客户)的访谈以及对近期case业绩的评估来做出。初步的排名结果还会由研究员和编辑进行分析讨论,综合各方因素后确定最终排名。在需要的时候,还可针对少数疑问做一些补充研究。

    律所排名 | 排名方式和角度与个人排名大致相同,但还要兼顾团队协作、内部机制和人员变动等方面,综合考虑该业务部门的广度和深度。不难发现,律所排名会和该所的律师排名成部分正相关,这也可以理解,因为上榜优秀个人律师越多,也可以侧面反映这些律师所属律所(部门)的实力越强。当然,也存在有些所的个人律师上榜,而律所无缘榜单的情况,这种情况则说明钱伯斯对其个别律师表示认可,而律所的整体实力仍需努力。需要指出的是,钱伯斯的律所排名仅针对的是该所相应的业务部门,比如A律所排在中国榜单某领域的band 2,仅能代表该所在该领域的团队实力,而不能反映该所的在其他领域或是全部的实力。

    无论是律师个人还是律所排名,钱伯斯并没有一个明确的硬性规定来划定入榜界限或者不同band 之间的界限。在排名中通常会有一个横向比较的过程。通过之前的各个维度的考量以及定量和定性分析,研究员可以充分了解律所/个人的去年活跃程度,知道哪些律所和律师的业务情况相较于他人或者整体市场呈上升/下滑趋势,以此来对往年的榜单进行修正,以制作出更反映实际市场情况的榜单来。

    【钱伯斯排名中都有哪些榜单】

    钱伯斯排名首先将律所区分为中资律所和外资律所,相对应的中国榜单分别是PRC Firms 和 International Firms。

    其次,钱伯斯将法律市场细分为不同的领域或细分领域。从2015年的钱伯斯榜单(中资律所)来看,排名覆盖了从“Banking and Finance银行金融”到“TMT”通信媒体的近20个大领域。由于各个法律领域的特点不同,不少榜单还有子榜单,比如“Capital Market资本市场”就分为“Capital Market: Debt & Equity资本市场:债务与股权”和“CapitalMarket: Securitization & Derivatives资本市场:资产证券化与衍生品”,而“债务与股权”部分又细分为“国内发行”和“香港及海外发行”两块。

    另外,由于法律业务领域是不断变化发展的,因此钱伯斯的榜单也不是一成不变的,会随着实际法律需求和趋势做出相应调整。有时根据业务需求会添加新的榜单,有的时候会拆分榜单,但整个中国地区榜单的基本框架和研究方法目前仍保持不变。

    此外,钱伯斯从2013年起连续三年发布了私人财富管理法律服务榜单。令人遗憾的是,目前没有中国律师事务所入选该榜单,但包括陈凯(Kai Chen)、王芳(Fang Wang)在内的多名律师以个人名义登陆该榜单,预示着一个向上的趋势。

  • Gmail SMTP Port

    1. SMTP 中继服务 – 用于通过验证 IP 地址,进而从您的单位发送邮件。您可以向网域内外的任何人发送邮件。
    2. Gmail SMTP 服务器 – 需要验证您的 Gmail/G Suite 帐户和密码。可向网域内外的任何人发送邮件。
    3. 受限 Gmail SMTP 服务器 – 无需进行身份验证。您只能向 Gmail 或 G Suite 用户发送邮件。

    以下表格可帮助您确定哪个选项最贴近您的需求:

    选项 G Suite SMTP 中继(推荐) Gmail SMTP 服务器 受限 Gmail SMTP 服务器
    SMTP 服务的完全限定域名 smtp-relay.gmail.com smtp.gmail.com aspmx.l.google.com
    配置要求 端口:25、465 或 587
    可选 SSL/TLS。
    需要一个或多个静态 IP 地址。
    端口:465(需要 SSL
    端口:587(需要 TLS)
    允许动态 IP
    端口:25
    无需 TLS
    允许动态 IP
    只能向 Gmail 或 G Suite 用户发送邮件
    yaoqiu身份验证 IP 地址提供身份验证。 需要验证您的完整 Gmail 或 G Suite 电子邮件地址 不需要。
    绕过反垃圾邮件 不。可疑的电子邮件可能被过滤。 不。可疑的电子邮件可能被过滤。 不。可疑的电子邮件可能被过滤。
    发送限制 针对已注册的 G Suite 用户的限制。
    已注册的用户每天最多能够向 10,000 名收件人中继邮件。
    要了解完整的 SMTP 中继限制,请参阅 SMTP 中继服务的发送限制
    2000 封邮件/每天。有关详情,请参阅发送限制 将根据每个用户的接收限制。
  • network test tool: nogotofail /Google

    https://github.com/google/nogotofail

    Nogotofail是一个网络安全测试工具。设计用于帮助开发人员和安全人员,以一个灵活、可扩展、功能强大的方式来识别和修复弱TLS/ SSL连接和应用与设备中的敏感明文流量。它测试包括对于普通SSL证书验证问题,HTTPS和TLS/ SSL库的Bug,SSL和STARTTLS剥离的问题,明文的问题,等等。

    Nogotofail只依赖于Python的2.7和pyOpenSSL>=0.13。

     

  • 寻找并删除Git记录中的大文件

    http://www.tuicool.com/articles/vAVVZrA

    寻找并删除Git记录中的大文件

    最近发现 HarttleLand的Git仓库 已经达到了142M,严重影响Fork和Clone。 今晨Harttle从Git记录中定位了数百个大文件并将其删除,现在仓库恢复了27M的大小。 借此机会,本文来介绍查找和重写Git记录的命令: git rev-list , git filter-branch

    首先通过 rev-list 来识别仓库记录中的大文件:

    git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"
    

    经过确认后,通过 filter-branch 来重写涉及到的所有提交:

    git filter-branch -f --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch your-file-name' --tag-name-filter cat -- --all
    

    Git仓库的存储方式

    如果你熟知Git的存储方式,跳过此节。

    Git仓库位于项目根目录的 .git 文件夹,其中保存了从仓库建立( git init )以来所有的代码增删。 每一个提交(Commit)相当于一个Patch应用在之前的项目上,借此一个项目可以回到任何一次提交时的文件状态。

    于是在Git中删除一个文件时,Git只是记录了该删除操作,该记录作为一个Patch存储在 .git 中。 删除前的文件仍然在Git仓库中保存着。直接删除文件并提交起不到给Git仓库瘦身的效果。

    在Git仓库彻底删除一个文件只有一种办法:重写(Rewrite)涉及该文件的所有提交。 幸运的是借助 git filter-branch 便可以重写历史提交,当然这也是Git中最危险的操作。 可以说比 rm -rf * 危险一万倍。

    从所有提交中删除一个文件

    我清楚地记得曾提交过名为 recent-badge.psd 的文件。这是一个很大的PhotoShop文件,我要把它删掉。 filter-branch 命令可以用来重写Git仓库中的提交, 利用 filter-branch--index-filter 参数便能把它从所有Git提交中删除。

    $ git filter-branch -f --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch assets/img/recent-badge.psd' --tag-name-filter cat -- --all
    Rewrite 2771f50d45a0293668a30af77983d87886441640 (264/982)rm 'assets/img/recent-badge.psd'
    Rewrite 1a98ecb3f39e1f200e31754714eec18bc92848ce (265/982)rm 'assets/img/recent-badge.psd'
    Rewrite d4e61cfb1d88187b0561d283e663b81b738df2c7 (270/982)rm 'assets/img/recent-badge.psd'
    Rewrite 4ba0df06b26cf86fd39c2cda6b012c521cbc4dc1 (271/982)rm 'assets/img/recent-badge.psd'
    Rewrite 242ae98060c77863f5e826ba7e1ec47
    

    --index-filter 参数用来指定一条Bash命令,然后Git会检出(checkout)所有的提交, 执行该命令,然后重新提交。我们在提交前移除了 recent-badge.psd 文件, 这个文件便从Git的所有记录中完全消失了。

    --all 参数告诉Git我们需要重写所有分支(或引用)。

    寻找大文件的ID

    删掉了 recent-badge.psd 后我仍不满足,我要找到所有的大文件,并把它删掉。 verify-pack 命令用来验证Git打包的归档文件,我们用它来找到那些大文件。 例如:

    $ git verify-pack -v .git/objects/pack/*.idx
    8fa15d279de33ce28a3289fd33951374084231e4 tree   135 137 144088922
    a44a50b2ffb1f8283c8e64aafb8e7628249d7453 tree   33 43 144089059
    b57d99f38fe22491e4a2d30c2b081ecb7bbb329c tree   99 97 144089102
    2d4ffaffc11758d561ea1a6d57dd8ee17ee1d836 blob   644952 644959 144089199
    8cf81ebfeec409f19e7a47a76517317f3bfa268d blob   695898 695871 144734158
    ...
    

    -v (verbose)参数是打印详细信息。

    输出的第一列是文件ID,第二列表示文件(blob)或目录(tree),第三列是文件大小。 现在得到了所有的文件ID及其大小,需要写一点Bash了!

    先按照第三列排序,并取最大的5条,然后打印出每项的第一列(这一列是文件ID):

    $ git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -10 | awk '{print$1}')"
    f846f156d16f74243b67e3dabec58a3128744352 
    4a1546e732b2e2a352b7bf220c1a22ad859abf89 
    f72d04efe6d0b41b067f9fbbc62455f28d3670d2 
    49bdf300ddf57d1946bc9c6570d94a38ac9d6a50 
    9c073d4177af5d2e43ada41f92efb18d9462a536
    

    现在变得到了最大的5个文件的ID,而我需要文件名才能用 filter-branch 移除它。 我现在需要文件ID和文件名的映射关系。

    文件名与ID映射

    rev-list 命令用来列出Git仓库中的提交,我们用它来列出所有提交中涉及的文件名及其ID。 该命令可以指定只显示某个引用(或分支)的上下游的提交。例如:

    git rev-list foo bar ^baz
    

    将会列出所有从 foobar 可到达,但从 baz 不可到达的提交。我们将会用到 rev-list 的两个参数:

    • --objects :列出该提交涉及的所有文件ID。
    • --all :所有分支的提交,相当于指定了位于 /refs 下的所有引用。

    我们看看这条命令的输出:

    $ git rev-list --objects --all
    c252878ac09a3979a80520b82a71dc2dae4529f9
    7bc7d05c6097063f531580ba4c32921464a6c456 _drafts
    dcce26ed53fbb869dc7d5b71742d2f9e523bfe42 _layouts
    414186c794a0d58695abb75c548bdbfec1de2763 _layouts/default.html
    1934eeffe3d242375510dff28cffa6de6b3de367 _layouts/post.html
    5f14647875f2177a6d37b8bfbcdb4629af595b64 _posts
    6cdbb293d453ced07e6a07e0aa6e580e6a5538f4 _posts/2013-10-12-2.md
    ...
    

    现在就得到了文件名(如 _posts/2013-10-12-2.md )和ID(如 6cdbb293d453ced07e6a07e0aa6e580e6a5538f4 )的映射关系。

    得到文件名列表

    前面我们通过 rev-list 得到了文件名-ID的对应关系,通过 verify-pack 得到了最大的5个文件ID。 用后者筛选前者便能得到最大的5个文件的文件名:

    $ git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"
    f846f156d16f74243b67e3dabec58a3128744352 assets/img/recent-badge.psd
    4a1546e732b2e2a352b7bf220c1a22ad859abf89 assets/img/album/me/IMG_0276.JPG
    f72d04efe6d0b41b067f9fbbc62455f28d3670d2 assets/img/album/me/IMG_0389.JPG
    49bdf300ddf57d1946bc9c6570d94a38ac9d6a50 assets/img/album/me/IMG_0813.JPG
    9c073d4177af5d2e43ada41f92efb18d9462a536 assets/img/album/me/IMG_0891.JPG
    

    先把上面输出存到 large-files.txt 中。还记得吗? --tree-filter 参数中我们需要给出一行的文件名列表。上述列表我们需要处理一下:

    $ cat large-files.txt| awk '{print $2}' | tr '\n' ' '
    assets/img/recent-badge.psd assets/img/album/me/IMG_0276.JPG assets/img/album/me/IMG_0389.JPG assets/img/album/me/IMG_0813.JPG assets/img/album/me/IMG_0891.JPG
    

    现在便得到了一行的文件列表。把它存到 large-files-inline.txt 中。

    删除所有大文件

    现在得到了要删除的大文件列表 large-files-inline.txt ,把它传入到 --tree-filter 中即可:

    git filter-branch -f --prune-empty --index-filter "git rm -rf --cached --ignore-unmatch `cat large-files-inline.txt`" --tag-name-filter cat -- --all
    

    注意这里 --index-filter 的参数要用双引号,因为 cat large-files-inline.txt 还需要Bash的解析。

    至此已经干掉了那些大文件,来看看瘦身了多少吧! 注意 filter-branch 之后 .git 目录下会有大量的备份。 需要克隆一份当前仓库来看效果:

    git clone --no-hardlinks file:///Users/harttle/harttle.com /tmp/harttle.com
    

    仓库大小变为25.76M了!从原来的142M!

    也可以进入项目目录通过 du -d 1 -h 查看磁盘占用的大小。

    当然到此为止我们更改的都是本地仓库,现在把这些改变Push到远程仓库中去!

    git push origin --force --all
    

    因为不是fast forward,所以需要指定 --force 参数。

    这里的 --all 会将所有分支都推送到 origin 上。当然你也可以只推送 master 分支: git push origin master --force 。但是!如果其它远程分支有那些大文件提交的话,仍然没有瘦身!

    参考阅读

  • Send DKIM signed message

    https://www.limilabs.com/blog/sign-emails-with-dkim

    https://support.rackspace.com/how-to/create-a-dkim-txt-record/

    http://www.mecatronica.eesc.usp.br/wiki/index.php/Verifiying_DKIM_signatures

    http://dkim.org/specs/rfc4871-dkimbase.html

     

    Quick reference to Internet message headers:

    https://www.cs.tut.fi/~jkorpela/headers.html

     

    HOWTO define DKIM/ADSP RRs

    http://www.zytrax.com/books/dns/ch9/dkim.html#examples

     

    Online Test Tool:

    https://mxtoolbox.com/SuperTool.aspx

    http://www.appmaildev.com/

    https://dmarc.org/resources/deployment-tools/

     

    DMARC

    https://dmarc.org/

    https://dmarc.globalcyberalliance.org/

    Specification

     

    DMARC resource record in the DNS

    "v=DMARC1;p=reject;pct=100 rua=mailto:postmaster@dmarcdomain.com"

    Tag Name Purpose Sample
    v Protocol version v=DMARC1
    pct Percentage of messages subjected to filtering pct=20
    ruf Reporting URI for forensic reports ruf=mailto:authfail@example.com
    rua Reporting URI of aggregate reports rua=mailto:aggrep@example.com
    p Policy for organizational domain p=quarantine
    sp Policy for subdomains of the OD sp=reject
    adkim Alignment mode for DKIM adkim=s
    aspf Alignment mode for SPF aspf=r

    Refer to

    https://tools.ietf.org/html/rfc7489#page-16

     

    Google, Microsoft, Yahoo

    https://dmarc.globalcyberalliance.org/my-cloud-email-provider-supports-dmarc-do-we-still-need-to-implement-it.html

     

    Troubleshooting

    Gmail: https://support.google.com/a/answer/3726730?hl=en

    Outlook.com: https://mail.live.com/mail/troubleshooting.aspx

    Yahoo: https://help.yahoo.com/kb/mail/practices-senders-sln3435.html

    AOL: http://postmaster.aol.com/Postmaster.Troubleshooting.php

    https://www.mailenable.com/kb/content/article.asp?ID=ME020003