Total Pageviews

Tuesday 30 April 2024

習大大的心底很慌

其實習大大的心底是很慌的。他深知此時中國沒有與美國衝突的本錢,但他也沒有退縮服軟的空間。他跟拿破崙三世一樣,借了常勝將軍先人的名號,一個借了拿破崙,一個借了毛澤東,現在一退讓或一戰敗,便將身首異處。所以他現在既不能戰,也不能退,只能硬著頭皮充胖子,烙狠話,充面子,將所有衝突的罪責歸於對方。這就像市場裡的小混混,喊著:「你不要過來喔!再過來我打死你喔!你不要隨便挑釁喔!」但身體卻不自主的往後退。那是一種魯迅說的阿Q式精神勝利法,只要在心理上說對方是十惡不赦的惡霸,必遭天譴,我暫時忍讓是為了避免血流成河,便在精神上獲得了寬慰。

 

這種精神勝利法在央視露出的那個美中南海軍機鎖定事件中,得到了完美的演示。眾所周知,軍機一旦遭到鎖定,下一步便是開火發射飛彈,那就大概逃不了了。美軍戰機鎖定了共軍戰機,在模擬空戰演練中,就是共機敗了。只是因為現在是承平時期,沒有按下發射鍵罷了。但中共飛行員卻把故事講得像是自己無比偉大,不屈不撓,技術過硬,才能脫鎖,安全歸來。這是整個體系的「虛假敘事」,不是要騙別人,純粹的自己騙自己,是真正的可恥又可悲。

 

再看外媒露出習近平在等待布林肯時,不斷的來回跺方步,身體老人搖,面部表情垂頭喪氣,更印證了這種精神勝利法的判斷。中方實際上對美方的各種制裁完全無力應對,卻又不得不嘴硬,對布林肯等下會說出什麼話?心裡完全沒底,只能大話西遊一番。實際上,王毅講的一連串「不」與「停止」,正是中方最怕的事。舉個例來說,要求美方停止在菲律賓佈署陸基中程飛彈,不要搞圍堵小圈圈,那就是他們心底最怕的東西,真正讓他們感到痛的東西。美方沒有說一套做一套,老美是已經做完一整套,再告訴你我有這一套,要打要談,要戰要和,要進要退,你自個兒看著辦。

 


最慘的是,習大大徹底暴露了他的虛弱與無奈。跺方步視頻鐵定是牆內人自己流出來的,這顯示中共並不是鐵板一塊,而是瑞士乳酪,不滿習的人大有人在。習的一切作為,顯示他正如曹操煮酒論英雄時評論袁紹的台詞:「色厲而膽薄,好謀而無斷,臨大事而惜身,見小利而忘命,非英雄也。」真正的英雄豪傑,是笑笑的把人殺了,談笑間強虜灰飛煙滅,而這位老習,是成天喊著殺殺殺,卻讓人看破手腳而笑翻了,只得一個「慘」字來形容啊!

 

接下來,美中雙方只能走向硬碰硬,很難再有機會手牽手,尤其當美國與印太盟國已經建立起肩併肩的關係,中方最終也只能選擇與俄羅斯背靠背。習大大老喊著不要新冷戰,卻一手造就了比冷戰還冷的集團對抗關係,這能怪誰?天堂有路你不走,地獄無門你偏闖,給過你無數修正路線的機會,你卻當成別人的軟弱,與自己再騙一次的機會,現在想再回頭,已經沒路了。

 

布林肯的這次訪中,可說是美中關係的劃時代轉折點。中方對布林肯的侮慢,布林肯忍了下來,卻是記帳在案,可能加倍奉還。美方對中的強硬態度與圍堵戰略,既不藏也不演了,而是擺出要來就來,要打就打的態勢,連偷襲珍珠港的賤招都做好了防備,將基地分散到整條西太平洋防線上。所以,中國只能屈服,沒有其他路可走。美國也沒有尋求改變中國的體制,而是靜待中國的體制內自己發生動亂。這種格局應會持續一段時間,至少撐過520,接下來,就看雙方領導者的智慧了。

 

※作者為前親民黨文宣部副主任、專欄作家

美中關係已經度過奈何橋──布林肯訪中之後的中美對抗


 宋國誠 / 上報 20240429

以態度輕鬆、立場嚴肅的姿態,美國國務卿布林肯4月26日結束了北京之行,完成了對中國遞出「最後通牒」的任務,特別是在離別記者中拋出一句重話:中國如果不處理雙邊的分歧,我們自己來處理」,換言之,苦口婆心、好話說盡,如果中國依然逃避耍賴,給你胡蘿蔔不吃,那就祭出大棍棒

 

美國結束「牧羊人主義/預防外交政策」

 

儘管美國外交政策存在一種「後設思維」(meta thinking)-外交思惟背後的「前意識」-白人基督教的「牧羊人主義」-道德教化主義,也就是美國外交政策的一種「愛的教育」;但是,此後美國不再扮演「牧羊人」,改由擔任「狩獵人」,那就是瞄準中國這頭桀傲不遜的野牛,一槍斃命

 

儘管美國深信「預防外交政策」(Preventive Diplomacy Policy)-管控分期、設置護欄、避免衝突,認為通過外交斡旋可以降低中國的野心,也就是拜登政府常講的「妥善管理美中衝突」;換言之,美國始終希望以「溝通」構築美中之間的友誼橋樑,但是,友誼橋已經變成奈何橋,預防外交已經轉向「懲罰外交」: 以對抗代替談判。

 

美國始終希望以「溝通」構築美中之間的友誼橋樑,但是,友誼橋已經變成奈何橋,預防外交已經轉向「懲罰外交」。(美聯社)

 

儘管美國的外交作為內含一種「美國式的危機管理哲學」,也就是美國國安顧問蘇利文與副國務卿坎貝爾2019年在《外交事務》(Foreign Affairs) 期刊中講的一句「畫龍點睛」的關鍵詞:「競爭但不惹禍」(competition without catastrophe),認為通過風險管理可以營造公平競爭的環境。但是,當前美中之間的競爭已經結束,迎來的是對抗

 

美國敘事vs 中國敘事

 

為何斷言美中關係已度奈何橋?這可從美中之間的「話語交鋒」(美國敘事vs 中國敘事)得到證明:

 

(1)美國說要「管控分歧」,中國就拿筆「畫紅線」;楚河漢界,誰都不理誰。

 

(2)美國主張「自由開放的印太」,中國就回懟「南海是中國的主權領土,台灣是中國核心利益」;

 

(3)美國說要「負責任管理分歧」,中共反嗆「一切後果由美方負責」;

 

(4)美國指責中國財政補貼、濫用非市場經濟,中國反控美國妨礙中國的正常貿易;

 

(5)美國責怪中國產能過剩、低價傾銷,中國辯稱美國打壓中國產業發展。

 

(6)美國宣稱「去風險」,中國硬指美國「製造風險」;

 

(7)美國建議雙方應該公平競爭,中國回嘴美國是「惡性競爭」

 

(8)美國要求中國停止援助俄羅斯,中國反駁這是「中俄正常貿易」;

 

(9)美國強調「負責任的管理彼此的分歧」,中國(習近平)卻說:「得其大者可以兼其小」(語出歐陽修),意思是指美國目光如豆!

 

(10)美國警告中共不要支援俄羅斯,中國(習近平)說:雙方都可以有自己的朋友和夥伴,不要針對對方,不要反對對方,不要損害對方。這裡的「對方」就是中國,意思是美國不要干涉中國內政。

 

中共說:布林肯是來討飯的

 

我常說習近平路線叫做「蠻牛撞牆,末路狂奔」,這可以從布林肯人尚未來到中,中共就祭出「反咬策略」得到驗證。中共官媒和民粹粉紅宣稱,布林肯是來中國討飯的!警告布林肯必須放低姿態,不得基於實力的立場對中國說話!換言之,中國採取的是「高壓作態」,也就是操縱輿論,鼓動反美風潮,利用「國民認知的武器化」,提前開打「情緒戰爭」。

 

中共官媒和民粹粉紅宣稱,布林肯是來中國討飯的!警告布林肯必須放低姿態,不得基於實力的立場對中國說話!(美聯社)

 

如此你來我往,只有惡言,何來溝通?只有叫罵,哪有交集?即使美國苦心規勸,中共也是虛與委蛇;換言之,布林肯即使去了中國100遍,去了也是白去!中共如果一定要跳入「修昔底德陷阱」,美國也莫可奈何!


美國有哪些「大棍棒」

 

美國如果不對中國祭出制裁,那就不是世界警察。一般來說,制裁的條件有二:一是戰略工具箱的較量,二是戰略決斷性的強弱。從美國主張的「競爭/危機管理」的外交原則來看,貯存於美國戰略工具箱占絕對優勢的軍事籌碼,應不致立即開箱出擊,但必將採取「非軍事手段最大化」的策略。這包括5項制裁手段:

 

1,貿易與金融制裁:擴大不僅針對特定產業(如鋼鐵、鋁材)的關稅壁壘,還將從電動動汽車、太陽能面板、鋰電池為起點的各種中國進口商品,採取「高關稅懲罰」,並且以25%的比率起跳

 

2,制裁中國「援俄銀行」,也就是切斷這些執行中俄貨幣交易的銀行與國際金融體系的聯繫(電匯轉帳功能),也就是將其踢出SWIFT(環球銀行金融電信協會)。儘管目前美方並未明說這一制裁手段,儘管基於美中貿易的高度互賴性,美國全面 (針對中國所有銀行) 實施此一制裁手段的可能性不高,但美國財政部長已經表明,已經把這一「核彈級」轟炸手段列入「可選擇項目」之一。一旦美國真是採取全面轟炸,中國人民幣必將失去主權貨幣下美金信用保證的支撐而貶得一文不直

 

3,擴大凍結中共高官隱藏於美國的資產。依據「2023美國國防授權法」第6501條,美國行政部門必須在今年年底以前,提出對中共官員在美資產的調查報告。範圍包括205名中央委員以上(含7常委、25名政治局委員、29名省委書記)的中共官員。換言之,如果必要,美國可以凍結或沒收這些資產,並且轉贈於需要美國援助的印太友邦。

 

4,外交降級。撤回美國駐華大史,或驅逐中共駐美大使。換言之,美國駐中大使伯恩斯回國升官,中共駐美大使(謝鋒)回家種田。

 

5,戰略壓迫。美國副國務卿坎貝爾已經宣稱,將與韓國展開「延伸嚇阻」(extended deterrence),也就是美韓核子共享政策,在「印太北三角」形成戰略圍堵;另一方面,美國也已證實,將在菲律賓呂宋島部署新型的「陸軍陸基飛彈發射系統」-「堤豐系統」(Typhon Weapons System),也可能包括「戰斧級」中程導彈,在「印太南三角」形成濱海遏制戰略。換言之,美國將以「南北夾擊」的方式,對中國形成空前的戰略壓迫。

 

「三個不認為」──美中關係隨時墜崖

 

布林肯這次訪中的最大收穫,不是繼續維持溝通管道,而是徹底認清了中共。這包括:

 

1,不認為中國能對以規則為基礎的國際秩序做出積極友善的回應

 

2,不認為中國會放棄侵略台灣和霸佔南海的野心。

 

3,不認為中國會跟美國合作;中國經常呼籲美國與中國「相向而行」,美國則已認定中國始終與美國「逆向而行」

 

美國積怨已久、憤怒已深,苦口婆心不成,那就動刀動槍。基於以上「三個不認為」,美國將採取最嚴厲的制裁措施。換言之,如果葉倫是「先禮」,那布林肯就是「後兵」,這意味著美中關係已經走到懸崖之邊,如臨深淵。美中關係不是緊繃,而是隨時可能墜崖。


 

※本文作者為政治大學國際關係研究中心資深研究員,中國問題與國際戰略學家

顏純鈎:從悶局困局到亂局危局,全世界都在等中共破局


政治學家吳國光教授最近提出了一個「破局」的新概念,高度概括了中共國當下面臨的最後關頭。

順吳教授的思路,我們可以理一下中共這幾十年來走的路。胡錦濤時代,開始了國進民退,那時政治經濟都找不到出路,陷入悶局;習近平上台後倒行逆施,有破壞,無建設,開始了長時間的困局;經過美中貿易戰﹑三年封控,無序放開﹑香港反送中,又陷入不可解的亂局;習近平不知悔改,內外交困,政治經濟社會難題疊加,互相激化,政府陷入失能的危局;危局無解,長期惡化,最終走向吳教授提出的破局

時至今日,全世界都看到中共面臨的破局了,不但中國大陸的知識精英和底層百姓,還有選擇躺平的年輕人,失業回鄉的農民工,都在等一個破局的出現。台灣人﹑香港人﹑海外中國人,在大陸之外圍觀中共處境,也無不在期待一個破局;各民主國家的政治領袖,關心世界大局的各國人民,也都在等中共何時走向破局。

沒有人相信中共可以從當下的危局中走出來,包括習近平自己在內,都不相信他有能力解決當下的危局,因此他一天到晚說大話以逃避現實,什麼新質生產力,什麼大食物觀,只有口號,沒有對策,官員無所適從,民眾離心離德。今日習近平的心態,只是捱一日算一日,準備應對最惡劣的日子,至於生死存亡,也只好問天了。

裡裡外外都在等破局,破局就一定會來臨,破局是必然,問題只是時間和形式。關於時間,要看中國民眾與各民主國家有多少作為,中共有多少能耐,關於形式,吳國光教授提到兵變與民變,提到李自成。

破局之始,有從中共內部發生,也有從外部發生兩種可能性,從中共內部發生,有宮廷政變與軍隊嘩變兩種方式。今日中國,像華國鋒主導活捉四人幫那種事變不可能發生,因為華當時是雙料主席,有軍隊與警衛部隊支持,嚴格說起來不是宮廷政變,只是清君側。今日習近平一手遮天,有蔡奇與軍頭護駕,不太可能發生宮廷政變。

軍隊嘩變是有可能的,一旦中央財政枯竭,軍餉發不出來,將在外,君命有所不受,那時軍隊的自主性便會升高,一旦上下矛盾激化,軍隊失控,嘩變就有可能,但那最終也是時間問題。

民變隨時都會發生,早前苗族村落與武警惡鬥,武警打輸被俘,關在村中大屋,後來雙方談判,村民聚集大路兩旁咒罵,目送武警垂頭喪氣撤出,那已經是一種低層次的民變。中共基層幹警作惡,踐踏百姓,民間怒火積聚,一點就燃,只要財政敗壞到一定程度,維穩經費拖欠,沒有人再替中共打生/打死,那時民間有人登高一呼,應者雲集,民變就會發生

少數民變不可怕,可怕的是民變遍地發生,蔚為風氣,亂民集結搶劫公共財產,購置武器,衝擊政府機關,基層百姓趁機發洩多年積累的怨氣,那時黨政機關一衝即潰。

但是,中國未來是不是會出現李自成式的民間英雄,揮軍北伐,逐鹿中原,與官方決一死戰而改朝換代,這卻很難說。農耕時代靠的是人力,人多必勝,現代戰爭靠的是武器,一支民間隊伍要與官方軍隊決生死,佔便宜的機會不高。除非兵變與民變同時發生,中央政府完全失能,如果是那樣,解決問題的也不是李自成了。

破局是不是會以一種開天闢地破舊立新的形式發生?我認為機會也不大,有人提出中國會因為經濟危機而導致和平轉型,那更是幻想。最大的可能是,中共因財政破產而失去對各級政府的控制,地方政府要生存,只好以各自可行的辦法,與民間社會達成地方性的和解和解的方式各有不同,各省只能依本身既有的條件去運作,那時偌大中國分裂成幾十個相互獨立的政治實體,各自為政,那便是破局的開始

這種全面解體的形勢,一定要經歷幾十年的長時間混亂,各省之間有衝突也有合作,不同省份之間有制度競爭,好的制度會得到長足進步,壞的制度會很快崩潰。長時間磨合的結果,是人民的選擇會向好的制度傾斜,到那時,全國性的和解﹑談判,取得共識,那才是國家重建的新歷史契機。

不破不立,沒有經歷一個破局,不可能產生一個新局。破局是先推翻共產黨的統治,中共倒台後,人民自謀生路,雖然將經歷一段痛不欲生的艱難時期,但不如此,無以新生。

裡裡外外都在等,等一個破局出現,中共在為自己掘墓,人民在為中共造墳。歷史的走向有其不可違逆的規律,但歷史走向一定以大多數人的意志為依歸

普大帝的新衣“铁布衫”

 

在俄乌战争之前,俄罗斯是威震世界的一极,即便它的GDP只相当于大国一个省的规模,即便它靠出卖资源过日子,但从没哪个国家敢不重视它,因为它有把地球毁灭几次的核力量。想把地球建设好的国家总是害怕有力量毁灭地球的国家,全世界想过好日子的人们得哄着有巨大破坏力的人希望他日子过得顺心,对生活充满留恋,不让它有自暴自弃的情绪。所以,普帝耍脾气打格鲁吉亚,找别扭占了克里米亚,西方人虽然恨得要命但更怕得要死,想着各种花样跟大帝谈人生聊和平,把“己之不欲勿施于人”的道理掰碎揉细了讲,大帝只淡淡回了句“我欲”,意思是“我之所欲必施于人”。西方人只能做做姿态就哑火了,主要是大帝身后的核武库太吓人,“不看僧面看核面”吧。

如果大帝就此止步,世界仍然颤栗在核阴影下,继续向俄罗斯输送利益,满足俄罗斯的欲望就是维护世界的稳定,全世界都在向俄罗斯缴纳“核慑税”。大帝守着核武库,“引而不发,跃如也”,哪怕核武库其实早空了,也能坐吃空饷,毕竟没有谁敢以身验核。(普大帝不知道见好就收的道理,反而害了自己

全世界的溺爱把大帝惯坏了,西方国家的忍让和绥靖鼓励了他的欲望,又发起了“特别军事行动”。有欲就必施于人,大家能理解,但吃伟哥纵欲过度,这啥时候是个头呀。本来,西方习惯性地想再当缩头乌龟,劝泽连斯基逃跑组织流亡政府,反正占着理卖惨总有一口饭吃。没想到演员出身的泽连斯基一眼就看出这场千载难逢的大戏,第一幕挂着的枪随剧情发展会在大帝身上打响。于是,欧美硬着头皮援助了四菜一汤——标枪、毒刺导弹、无人机、海马斯火炮及头盔,陪泽连斯基、普帝喝上了。当初德国只敢援助五千顶头盔,后来不好意思了,又给头盔加了防磨软垫,不磨头了。

欧美的援助很费心思,仔细盘算着如何既不让俄军被打得太痛以至于发怒动核,又让乌克兰能够顶住进攻,如能逼俄军知难而退则皆大欢喜。欧美在婊子与牌坊之间走钢丝,俄罗斯不断划红线干扰钢丝,每条红线上都挂着核威慑或核咋呼:

第一条红线:芬兰不能加入北约,否则就是对俄罗斯安全利益的挑战。

第二条红线:不允许向乌克兰提供进攻性武器。

第三条红线:不允许进攻俄罗斯本土,这是不可容忍的行为。

第四条红线:禁止轰炸克里米亚大桥。

第五条红线:禁止向乌克提供F-16.

第六条红线:禁止没收俄罗斯海外资产。

两年多以来,欧美顶着大帝、梅德韦杰夫一次次“核口炮”,蹑手蹑脚地踩踏了一条条红线,让核威慑活活变成了“喝威慑”,吆喝的威慑。

 

四月二十日,美国众议院通过了610亿美元的“援乌法案”后,普帝和梅德韦杰夫就再也没打过“核口炮”了,宣布没收80亿美元的俄资产援助乌克兰,更是骑在俄罗斯的脖子上拉屎了,俄方也不“核吆喝”了。

俄乌战争一开始,就此有方家指出俄方的核威慑就是昂贵的摆设,即使想自杀也挂不起这么粗的绳子上吊。也就是说,俄国领导就算想壮烈殉国,也用不起这么昂贵的自杀方式。武大郎只配喝碗砒霜毙命,西门大官人才有财力吃胡僧的壮阳药,精尽人亡。同归于尽是理想,理想很丰满,现实很骨干,柯镇恶倒是想跟黄药师拼个同归于尽,但武功忒低,办不到。有多少拳击手想跟泰森拼个鱼死网破,但连同台竞技的资格都没有。几十年前,俄罗斯的前身貌似有与美国同归于尽的能力,现在已经没有威慑的资格了,核点火之时就是俄罗斯的自我毁灭之日,而且拉不了别人陪葬。

核威慑是皇帝的特种新衣“铁布衫”,北韩号称已经裁剪得好合体,小金一身铁布衫“振衣千仞岗,濯足万里流”。伊朗朝思暮想打造铁布衫,幻想着新装加身,号令四方。本来,普帝有最宽敞最拉风的新衣,最护体的铁布衫,只要避免围观就可长袖裸舞。但俄乌战争开战以来,普帝画了大量红线,弄得裸体“铁布衫”一道道血痕,暴露了“铁布衫”核新衣其实一丝不挂。这就出卖了世界上穿核威慑铁布衫的各位帝爷,可怕的童稚声响亮—他们什么也没穿!普帝以一身之裸,暴露了全部光腚汉,让北朝、伊朗怎么讹人?

当世界看透了俄国的核讹诈就是麻将桌上的“诈和”时,永久和平就成为可能了。当普帝被彻底打败时,他为万世开太平的贡献不应抹杀。黑格尔的历史哲学有个“历史的诡计”概念,意思是某个独裁者为满足私欲干了件大坏事,却带来相反的结果,让文明因此而进步,坏心眼子却促成了好事。普帝为了比肩彼得大帝的虚荣发动了“特别军事行动”,却暴露了“核铁布衫”其实是一丝不挂,帮人类克服了核恐惧,普京居功至伟

欧美不但要加强援乌力度以确保打败俄罗斯,还要做好俄国失败后的白事安排,更要通过各种渠道实施“临终关怀”,让核威慑体面下葬,让俄国精英节哀顺变。在俄罗斯人的强国肥梦破灭后,及时置换忧郁,体贴俄罗斯人的诗情:梦见瘦的诗人将眼泪擦在最末的花瓣上,告诉她秋虽然来,冬虽然来,而此后接着还是春,胡蝶乱飞,蜜蜂都唱起春词来了。她于是一笑,虽然颜色冻得红惨惨地,仍然瑟缩着。

颜色冻得红惨惨地,仍然瑟缩着”是俄罗斯未来应有的形象

 

2024.4.28

顏純鈎:布林肯話中有骨,美中關係低處未算低


布林肯來去匆匆,臨走撂下一句狠話:「如果中國不着手解決這個問題,我們就會着手解決」。這是迄今為止美國人說的最重的一句話,表面上雲淡風輕,但棉裡藏針,話中有骨。
中國不會收歛援俄的暗招,美國人早識穿,以美國人對中共的了解,不可能對此抱有幻想,雖然如此,有話還是要說在前面。美國與北約國家,不可能靜觀俄國消滅烏克蘭,因為北約與俄國也是此消彼長的關係,有你冇我,你死我活。
北約在俄烏戰之初,指望借烏克蘭拖垮俄國,可惜這一招行不通,因為俄國後面站著中共。俄國拖不死,現實卻是烏克蘭被拖到半死不活,再遷延下去,一旦烏克蘭先垮,直接受威脅的就是北約。
法國總統馬克龍一度與中共眉來眼去,還狗屁顛顛訪問中國,與習近平杯酒言歡。近日馬克龍突然轉性,甚至不等北約共同行動,先行派兵進駐烏克蘭,直接參戰了,這表示法國已失去耐性。
美國的援烏法案近日獲參眾兩院通過,拜登即時簽署作實,美國最先進的武器連夜運往烏克蘭,這也顯示,美國人也正在失去耐性,連先前「阻頭阻勢」的特朗普,也出聲為烏站台。
美國與北約想盡快結束俄烏戰,中共援俄便成為最迫切的難題,有中共援俄,美國與北約的戰略企圖便大打折扣,美國北約要挫敗普京,唯有斬斷中共的魔爪。
此所以布林肯撂下重話,這一次,美國如果還是出聲唔落力,美國的立場與實力,將受到盟友質疑,也會被敵營看穿。雖然布林肯對制裁中共手法秘而不宣,但美國一定有暗盤在手,差別只是輕重早晚的選擇而已。
美國當然不會一下子就「去到盡」,去到沒有回頭路﹑與中共徹底決裂,美中準備開戰那種地步,不會一下子就掐住中共咽喉,逼狗入窮巷。美國很大可能會動用金融手段,制裁一部份有援俄罪行的地方性小銀行,小試牛刀,露一手給中共看看,讓中共吃一點苦頭,然後看形勢發展,再考慮升級
正常情況下,美國最大的弱點是國內政治,正因民主黨與共和國爭執政權與話語權,互相絆腳,導致國家戰略決策慢半拍,但不管哪個政黨,不管是官方民間,不管是華爾街大老闆還是尋常百姓,最終都站在美國利益的立場,當下朝野最統一的政治認知,便是中共是美國最大的敵人。因此,削弱中共,不讓中共騎在美國人頭上作威作福,這已經是美國社會最大的共識,有此共識為基礎,形勢又發展到美國已沒有讓步空間的危重關頭,拜登政府便沒有退路
這一次美國如果空口說白話,那在國際社會的威望將遭遇重大打擊。北約盟國將大失所望,亞太地區的日韓菲台,也都將對美國的實質支援抱懷疑態度,拜登政府好不容易建立起來的﹑西方國家的團結將大大削弱。美國有膽說冇膽做,也會被中共看穿手腳。
美國與北約不可能眼看烏克蘭被佔領,中共也不可能眼看普京吃敗仗,烏克蘭今日變成東西兩個陣營的兵家必爭之地。在戰略態勢上,誰贏,誰就贏大局,誰輸誰就失大勢,因此雙方都沒有後退之餘地。對美國來說,退就要重起爐灶,過程代價更大,對中共來說,普京戰敗中共即無死所。
美中對抗無解,只會加深,不會減輕,只會升級,不會降格。習近平現在也吃了秤砣,鐵了心,明白美中關係無可挽回,他能做的,只是加緊官場整肅,加重國內整治,準備捱苦日子。關起門來做皇帝,把民間反抗壓下去,然後靠國內生產能力與市場消費維持「內循環」,把獨裁統治勉強維持下去。
這種局勢,如果放在十年前,中國經濟還剛剛走弱的時候,那時中共還有足夠財力,官方民間還有一點互信,可以支撐更久一點。今日到處是破敗景象,國庫空虛,民間叫苦,社會醞釀動盪,外部朋友星散,強敵壓境,這種形勢下與美國硬碰硬,沒有正式交手,已敗象畢呈
習近平會見布林肯前,心神不定,被鏡頭現場捕捉,正是國勢不濟的呈現。口硬心虛,死馬當活馬醫,破罐子破摔,便是今日中共上下的心態。歷史進入垃圾時間,美中關係也在垃圾堆中快速爛下去。





Monday 29 April 2024

SSH connection via SOCKS proxy, and FTP connection via SOCKS proxy

 

Since the SOCKS proxy performs at Layer 5 of the OSI model (the session layer), you may use it with many applications that work in a Layer higher than Layer 5, such as FTP, Telnet, HTTP, SSH…

SSH via SOCKS proxy

For example, if you want to SSH to a Far_Away_Host via the SOCKS proxy we just created. You can do:

$ ssh -o ProxyCommand='nc -x localhost:12345 %h %p' username@Far_Away_Host

After login into the Far_Away_Host, you can check that you are deemed as connected from SSH_remote_host_IP instead of your local machine!

username@Far_Away_Host$ who  
username pts/3 2021-03-29 14:08 (SSH_remote_host_IP)

FTP via SOCKS proxy

Another example is the SOCKS proxy setting in FileZilla, an FTP client:

SOCKS proxy setting in FileZilla

Further Reading

There is a convenient tool — sshuttle suggested by smw on Hacker News. It works as a poor man’s VPN using ssh, which also doesn’t require admin on the remote machine. The manual is here. It can be easily installed on, e.g., macOS and Ubuntu via:

# on Ubuntu
$ sudo apt install sshuttle
# on macOS, installed by macports
$ sudo port install sshuttle

The simplest way to use it is:

$ sshuttle -r username@SSH_remote_host_IP 0.0.0.0/0

, which forwards all traffics on your local machine to the remote host!

Spring-AI

 An Application Framework for AI Engineering.

https://docs.spring.io/spring-ai/reference/1.0-SNAPSHOT/index.html

 build status

Welcome to the Spring AI project!

The Spring AI project provides a Spring-friendly API and abstractions for developing AI applications.

Let's make your @Beans intelligent!

For further information go to our Spring AI reference documentation.

Project Links

Educational Resources

Some selected videos. Search YouTube! for more.

  • Spring Tips: Spring AI
    Watch Spring Tips video
  • Overview of Spring AI @ Devoxx 2023
    Watch the Devoxx 2023 video
  • Introducing Spring AI - Add Generative AI to your Spring Applications
    Watch the video

Getting Started

Please refer to the Getting Started Guide for instruction on adding your dependencies.

Note, the new Spring CLI project lets you get up and running in two simple steps, described in detail here.

  1. Install Spring CLI
  2. Type spring boot new --from ai --name myai in your terminal

Adding Dependencies manually

Note that are two main steps.

  1. Add the Spring Milestone and Snapshot repositories to your build system.
  2. Add the Spring AI BOM
  3. Add dependencies for the specific AI model, Vector Database or other component dependencies you require.

Overview

Despite the extensive history of AI, Java's role in this domain has been relatively minor. This is mainly due to the historical reliance on efficient algorithms developed in languages such as C/C++, with Python serving as a bridge to access these libraries. The majority of ML/AI tools were built around the Python ecosystem. However, recent progress in Generative AI, spurred by innovations like OpenAI's ChatGPT, has popularized the interaction with pre-trained models via HTTP. This eliminates much of the dependency on C/C++/Python libraries and opens the door to the use of programming languages such as Java.

The Python libraries LangChain and LlamaIndex have become popular to implement Generative AI solutions and can be implemented in other programming languages. These Python libraries share foundational themes with Spring projects, such as:

  • Portable Service Abstractions
  • Modularity
  • Extensibility
  • Reduction of boilerplate code
  • Integration with diverse data sources
  • Prebuilt solutions for common use cases

Taking inspiration from these libraries, the Spring AI project aims to provide a similar experience for Spring developers in the AI domain.

Note, that the Spring AI API is not a direct port of either LangChain or LlamaIndex. You will see significant differences in the API if you are familiar with those two projects, though concepts and ideas are fairly portable.

Feature Overview

This is a high level feature overview. The features that are implemented lay the foundation, with subsequent more complex features building upon them.

You can find more details in the Reference Documentation

Interacting with AI Models

ChatClient: A foundational feature of Spring AI is a portable client API for interacting with generative AI models. With this portable API, you can initially target one AI chat model, for example OpenAI and then easily swap out the implementation to another AI chat model, for example Amazon Bedrock's Anthropic Model. When necessary, you can also drop down to use non-portable model options.

Spring AI supports many AI models. For an overview see here. Specific models currently supported are

  • OpenAI
  • Azure OpenAI
  • Amazon Bedrock (Anthropic, Llama, Cohere, Titan, Jurassic2)
  • HuggingFace
  • Google VertexAI (PaLM2, Gemini)
  • Mistral AI
  • Stability AI
  • Ollama
  • PostgresML
  • Transformers (ONNX)
  • Anthropic Claude3

Prompts: Central to AI model interaction is the Prompt, which provides specific instructions for the AI to act upon. Crafting an effective Prompt is both an art and science, giving rise to the discipline of "Prompt Engineering". These prompts often leverage a templating engine for easy data substitution within predefined text using placeholders.

Explore more on Prompts in our concept guide. To learn about the Prompt class, refer to the Prompt API guide.

Prompt Templates: Prompt Templates support the creation of prompts, particularly when a Template Engine is employed.

Delve into PromptTemplates in our concept guide. For a hands-on guide to PromptTemplate, see the PromptTemplate API guide.

Output Parsers: AI model outputs often come as raw java.lang.String values. Output Parsers restructure these raw strings into more programmer-friendly formats, such as CSV or JSON.

Get insights on Output Parsers in our concept guide.. For implementation details, visit the OutputParser API guide.

Incorporating your data

Incorporating proprietary data into Generative AI without retraining the model has been a breakthrough. Retraining models, especially those with billions of parameters, is challenging due to the specialized hardware required. The 'In-context' learning technique provides a simpler method to infuse your pre-trained model with data, whether from text files, HTML, or database results. The right techniques are critical for developing successful solutions.

Retrieval Augmented Generation

Retrieval Augmented Generation, or RAG for short, is a pattern that enables you to bring your data to pre-trained models. RAG excels in the 'query over your docs' use-case.

Learn more about Retrieval Augmented Generation.

Bringing your data to the model follows an Extract, Transform, and Load (ETL) pattern. The subsequent classes and interfaces support RAG's data preparation.

Documents:

The Document class encapsulates your data, including text and metadata, for the AI model. While a Document can represent extensive content, such as an entire file, the RAG approach segments content into smaller pieces for inclusion in the prompt. The ETL process uses the interfaces DocumentReader, DocumentTransformer, and DocumentWriter, ending with data storage in a Vector Database. This database later discerns the pieces of data that are pertinent to a user's query.

Document Readers:

Document Readers produce a List<Document> from diverse sources like PDFs, Markdown files, and Word documents. Given that many sources are unstructured, Document Readers often segment based on content semantics, avoiding splits within tables or code sections. After the initial creation of the List<Document>, the data flows through transformers for further refinement.

Document Transformers:

Transformers further modify the List<Document> by eliminating superfluous data, like PDF margins, or appending metadata (e.g., primary keywords or summaries). Another critical transformation is subdividing documents to fit within the AI model's token constraints. Each model has a context-window indicating its input and output data limits. Typically, one token equates to about 0.75 words. For instance, in model names like gpt-4-32k, "32K" signifies the token count.

Document Writers:

The final ETL step within RAG involves committing the data segments to a Vector Database. Though the DocumentWriter interface isn't exclusively for Vector Database writing, it the main type of implementation.

Vector Stores: Vector Databases are instrumental in incorporating your data with AI models. They ascertain which document sections the AI should use for generating responses. Examples of Vector Databases include Chroma, Postgres, Pinecone, Qdrant, Weaviate, Mongo Atlas, and Redis. Spring AI's VectorStore abstraction permits effortless transitions between database implementations.

Cloning the repo

This repository contains large model files. To clone it you have to either:

  • Ignore the large files (won't affect the spring-ai behaviour) : GIT_LFS_SKIP_SMUDGE=1 git clone git@github.com:spring-projects/spring-ai.git.
  • Or install the Git Large File Storage before cloning the repo.

Building

To build with running unit tests

./mvnw clean package

To build including integration tests. Set API key environment variables for OpenAI and Azure OpenAI before running.

./mvnw clean verify -Pintegration-tests

To run a specific integration test allowing for up to two attempts to succeed. This is useful when a hosted service is not reliable or times out.

./mvnw -pl vector-stores/spring-ai-pgvector-store -Pintegration-tests -Dfailsafe.rerunFailingTestsCount=2 -Dit.test=PgVectorStoreIT verify

To build the docs

./mvnw -pl spring-ai-docs antora

The docs are then in the directory spring-ai-docs/target/antora/site/index.html

To reformat using the java-format plugin

./mvnw spring-javaformat:apply

To update the year on license headers using the license-maven-plugin

./mvnw license:update-file-header -Plicense

To check javadocs using the javadoc:javadoc

./mvnw javadoc:javadoc -Pjavadoc
from https://github.com/spring-projects/spring-ai 
-------------------------------------------------------

Getting Started

This section offers jumping off points for how to get started using Spring AI.

You should follow the steps in each of the following section according to your needs.

Spring CLI

The Spring CLI, simplifies creating new applications directly from your terminal. Like the 'create-react-app' command for those familiar with the JavaScript ecosystem, Spring CLI provides a spring boot new command to create Spring-based projects. Spring CLI also offers features to integrate external code bases into your current project, and many other productivity features.


It is important to understand that the "Spring CLI" is a distinct project from the "Spring Boot CLI", each with its own set of functionalities.

To begin creating a Spring AI application, follow these steps:

  1. Download the latest Spring CLI Release and follow the installation instructions.

  2. To create a simple OpenAI-based application, use the command:

    spring boot new --from ai --name myai
  1. Consult the generated README.md file for guidance on obtaining an OpenAI API Key and running your first AI application.

To add the same simple AI application to an existing project, execute:

spring boot add ai

Spring CLI allows users to define their own project catalogs that define which projects you can create or add to your existing code base.

Spring Initializr

Head on over to start.spring.io and select the AI Models and Vector Stores that you want to use in your new applications.

Add Milestone and Snapshot Repositories

If you prefer to add the dependency snippets by hand, follow the directions in the following sections.

To use the Milestone and Snapshot version, you need to add references to the Spring Milestone and/or Snapshot repositories in your build file.

For Maven, add the following repository definitions as needed:

  <repositories>
    <repository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>spring-snapshots</id>
      <name>Spring Snapshots</name>
      <url>https://repo.spring.io/snapshot</url>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

For Gradle, add the following repository definitions as needed:

repositories {
  mavenCentral()
  maven { url 'https://repo.spring.io/milestone' }
  maven { url 'https://repo.spring.io/snapshot' }
}

Dependency Management

The Spring AI Bill of Materials (BOM) declares the recommended versions of all the dependencies used by a given release of Spring AI. Using the BOM from your application’s build script avoids the need for you to specify and maintain the dependency versions yourself. Instead, the version of the BOM you’re using determines the utilized dependency versions. It also ensures that you’re using supported and tested versions of the dependencies by default, unless you choose to override them.

If you’re a Maven user, you can use the BOM by adding the following to your pom.xml file -

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-bom</artifactId>
            <version>0.8.1-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Gradle users can also use the Spring AI BOM by leveraging Gradle (5.0+) native support for declaring dependency constraints using a Maven BOM. This is implemented by adding a 'platform' dependency handler method to the dependencies section of your Gradle build script. As shown in the snippet below this can then be followed by version-less declarations of the Starter Dependencies for the one or more spring-ai modules you wish to use, e.g. spring-ai-openai.

dependencies {
  implementation platform("org.springframework.ai:spring-ai-bom:0.8.1-SNAPSHOT")
  // Replace the following with the starter dependencies of specific modules you wish to use
  implementation 'org.springframework.ai:spring-ai-openai'
}

Add dependencies for specific components

Each of the following sections in the documentation shows which dependencies you need to add to your project build system.

Chat Models

 

 

Sunday 28 April 2024

蝸居地下,直擊"寄生上流"的半地下屋

 

被譽為"味蕾聯合國"! 泰國對外來文化接受度高 曼谷成台商心中兵家必爭之地 台裔老闆混搭菜色開創商機 日式燒肉搭配台灣滷味成功征服當地

 

-很想去台湾,新马泰,日本走一趟。

Java诊断工具: greys-anatomy


线上系统为何经常出错?数据库为何屡遭黑手?业务调用为何频频失败?连环异常堆栈案,究竟是哪次调用所为? 数百台服务器意外雪崩背后又隐藏着什么?是软件的扭曲还是硬件的沦丧? 走进科学带你了解Greys, Java线上问题诊断工具。

相关文档

程序安装

  • 远程安装

    curl -sLk http://ompc.oss.aliyuncs.com/greys/install.sh|sh
  • 远程安装(短链接)

    curl -sLk http://t.cn/R2QbHFc|sh

    最新版本

    VERSION : 1.7.6.6

    1. 支持JDK9
    2. greys.sh脚本支持tar的解压缩模式(有些机器没有unzip),默认unzip
    3. 修复 #219 问题

    版本号说明

    主版本.大版本.小版本.漏洞修复

    • 主版本

      这个版本更新说明程序架构体系进行了重大升级,比如之前的0.1版升级到1.0版本,整个软件的架构从单机版升级到了SOCKET多机版。并将Greys的性质进行的确定:Java版的HouseMD,但要比前辈们更强。

    • 大版本

      程序的架构设计进行重大改造,但不影响用户对这款软件的定位。

    • 小版本

      增加新的命令和功能

    • 漏洞修复

      对现有版本进行漏洞修复和增强

      • 主版本大版本、之间不做任何向下兼容的承诺,即0.1版本的Client不保证一定能正常访问1.0版本的Server。

      • 小版本不兼容的版本会在版本升级中指出

      • 漏洞修复保证向下兼容

    维护者

    程序编译

  • 打开终端

    git clone git@github.com:oldmanpushcart/greys-anatomy.git
    cd greys-anatomy/bin
    ./greys-packages.sh
    • 程序执行

      target/目录下生成对应版本的release文件,比如当前版本是1.7.0.4,则生成文件target/greys-1.7.0.4-bin.zip

      程序在本地编译时会主动在本地安装当前编译的版本,所以编译完成后即相当在本地完成了安装。

    心路感悟

    我编写和维护这款软件已经5年了,5年中Greys也从0.1版本一直重构到现在的1.7。在这个过程中我得到了许多人的帮助与建议,并在年底我计划发布2.0版本,将开放Greys的底层通讯协议,支持websocket访问。

    多年的问题排查经验我没有过多的分享,一个Java程序员个中的苦闷也无从分享,一切我都融入到了这款软件的命令中,希望这些沉淀能帮助到可能需要到的你少走一些弯路,同时我也非常期待你们对她的反馈,这样我将感到非常开心和有成就感。

    帮助我们

    Greys的成长需要大家的帮助。

    • 分享你使用Greys的经验

      我非常希望能得到大家的使用反馈和经验分享,如果你有,请将分享文章敏感信息脱敏之后邮件给我:oldmanpushcart@gmail.com,我将会分享给更多的同行。

    • 帮助我完善代码或文档

      一款软件再好,也需要详细的帮助文档;一款软件再完善,也有很多坑要埋。今天我的精力非常有限,希望能得到大家共同的帮助。

       from  https://github.com/oldmanpushcart/greys-anatomy

    mac系统的路由和DSN相关知识


    Mac下,上网,尤其是在双网卡一起使用的时候, 一个网卡连内网,一个网卡连外网,经常会碰到ip不通(路由问题,比较好解决)或者dns解析不了问题. 或者是在通过VPN连公司网络会插入一些内网route,导致部分网络访问不了.

    即使对Linux下的DNS解析无比熟悉了,但是在Mac下还是花了一些时间来折腾,配置不好路由和DNS是不配使用Mac的,所以记录下。

    route

    如果ip不通就看路由表, 根据内外网IP增加/删除相应的路由信息,常用命令如下:

    sudo route -n add 10.176/16 192.168.3.1
    sudo route -n add -net 10.176.0.0/16 192.168.3.1 //添加路由, 访问10.176.0.0/16 走192.168.3.1
    sudo route -n delete -net 10.176.0.0/16 192.168.3.1
    sudo route -n delete 0.0.0.0 192.168.184.1
    sudo route -n add 0.0.0.0 192.168.184.1 //添加默认路由访问外网
    sudo route -n delete 0.0.0.0 192.168.3.1
    sudo route -n add 10.176/16 192.168.3.1
    sudo route -n delete 0.0.0.0 192.168.184.1 -ifscope en0
    sudo route -n add 0.0.0.0 192.168.184.1
    sudo networksetup -setdnsservers 'Apple USB Ethernet Adapter' 202.106.196.115 202.106.0.20 114.114.114.114
    sudo networksetup -setdnsservers 'USB 10/100/1000 LAN' 223.5.5.5 30.30.30.30 114.114.114.114
    ip route get 8.8.8.8 //linux
    route get 8.8.8.8 //macos
    netstat -rn //查看路由
    netstat -nr -f inet //只看ipv4相关路由

    如果本来IP能通,连上VPN后就通不了,那一定是VPN加入了一些更精细的路由导致原来的路由不通了,那么很简单停掉VPN就能恢复或者增加一条更精确的路有记录进去,或者删掉VPN增加的某条路由.

    DNS 解析

    mac下DNS解析问题搞起来比较费劲,相应的资料也不多, 经过上面的操作后如果IP能通,域名解析有问题,一般都是DNS解析出了问题

    mac下 /etc/resolv.conf 不再用来解析域名, 只有nslookup能用到resolv.conf

    cat /etc/resolv.conf
    #
    # macOS Notice
    #
    # This file is not consulted for DNS hostname resolution, address
    # resolution, or the DNS query routing mechanism used by most
    # processes on this system.
    #
    # To view the DNS configuration used by this system, use:
    # scutil --dns
    scutil --dns //查看DNS 解析器
    scutil --nwi //查看网络

    解析出了问题先检查nameserver

    scutil –dns 一般会展示一大堆的resolver, 每个resolver又可以有多个nameserver

    A scoped DNS query can use only specified network interfaces (e.g. Ethernet or WiFi), while non-scoped can use any available interface.

    More verbosely, an application that wants to resolve a name, sends a request (either scoped or non-scoped) to a resolver (usually a DNS client application), if the resolver does not have the answer cached, it sends a DNS query to a particular nameserver (and this goes through one interface, so it is always “scoped”).

    In your example resolver #1 “for scoped queries” can use only en0 interface (Ethernet).

    修改 nameserver

    默认用第一个resolver, 如果第一个resolver没有nameserver那么域名没法解析, 可以修改dns resolver的nameserver:

    $networksetup -listallnetworkservices //列出网卡service, 比如 wifi ,以下是我的 macos 输出
    An asterisk (*) denotes that a network service is disabled.
    USB 10/100/1000 LAN
    Apple USB Ethernet Adapter
    Wi-Fi
    Bluetooth PAN
    Thunderbolt Bridge
    $sudo networksetup -setdnsservers 'Wi-Fi' 202.106.196.115 202.106.0.20 114.114.114.114 //修改nameserver
    $networksetup -getdnsservers Wi-Fi //查看对应的nameserver, 跟 scutil --dns 类似

    如上, 只要是你的nameserver工作正常那么DNS就肯定回复了

    删掉所有DNS nameserver:

    One note to anyone wanting to remove the DNS, just write “empty” (without the quotes) instead of the DNS: sudo networksetup -setdnsservers <networkservice> empty

    networksetup用法

    查看设备和配置

    $networksetup -listallnetworkservices
    An asterisk (*) denotes that a network service is disabled.
    USB 10/100/1000 LAN
    Apple USB Ethernet Adapter
    Wi-Fi
    Bluetooth PAN
    Thunderbolt Bridge
    Thunderbolt Bridge 2
    #查看网卡配置
    $networksetup -getinfo "USB 10/100/1000 LAN"
    DHCP Configuration
    IP address: 30.25.25.195
    Subnet mask: 255.255.255.128
    Router: 30.25.25.254
    Client ID:
    IPv6 IP address: none
    IPv6 Router: none
    Ethernet Address: 44:67:52:02:16:d4
    $networksetup -listallhardwareports
    Hardware Port: USB 10/100/1000 LAN
    Device: en7
    Ethernet Address: 44:67:52:02:16:d4
    Hardware Port: Wi-Fi
    Device: en0
    Ethernet Address: 88:66:5a:10:e4:2b
    Hardware Port: Thunderbolt Bridge
    Device: bridge0
    Ethernet Address: 82:0a:d5:01:b4:00
    VLAN Configurations
    ===================
    $networksetup -getinfo "Thunderbolt Bridge"
    DHCP Configuration
    Client ID:
    IPv6: Automatic
    IPv6 IP address: none
    IPv6 Router: none
    //查看wifi和热点
    networksetup -listpreferredwirelessnetworks en0
    networksetup -getairportnetwork "en0"

    dhcp、route、domain配置

    [-setmanual networkservice ip subnet router]
    [-setdhcp networkservice [clientid]]
    [-setbootp networkservice]
    [-setmanualwithdhcprouter networkservice ip]
    [-getadditionalroutes networkservice]
    [-setadditionalroutes networkservice [dest1 mask1 gate1] [dest2 mask2 gate2] ..
    . [destN maskN gateN]]
    #给网卡配置ip、网关
    $ networksetup -getinfo "Apple USB Ethernet Adapter" DHCP Configuration
    Client ID:
    IPv6: Automatic
    IPv6 IP address: none
    IPv6 Router: none
    Ethernet Address: (null)
    $networksetup -setmanual "Apple USB Ethernet Adapter" 192.168.100.100 255.255.255.0 192.168.100.1
    $networksetup -getinfo "Apple USB Ethernet Adapter"
    Manual Configuration
    IP address: 192.168.100.100
    Subnet mask: 255.255.255.0
    Router: 192.168.100.1
    IPv6: Automatic
    IPv6 IP address: none
    IPv6 Router: none
    Ethernet Address: (null)

    代理配置

    //ftp
    [-getftpproxy networkservice]
    [-setftpproxy networkservice domain portnumber authenticated username password]
    [-setftpproxystate networkservice on | off]

    网页

    [-getwebproxy networkservice]
    [-setwebproxy networkservice domain portnumber authenticated username password]
    [-setwebproxystate networkservice on | off]
    $networksetup -setwebproxy "Built-in Ethernet" proxy.company.com 80
    $networksetup -setwebproxy "Built-In Ethernet" proxy.company.com 80 On authusername authpassword

    Socks5 代理

    $networksetup -setsocksfirewallproxy "USB 10/100/1000 LAN" 127.0.0.1 13659
    $networksetup -getsocksfirewallproxy "USB 10/100/1000 LAN"
    Enabled: Yes
    Server: 127.0.0.1
    Port: 13659
    Authenticated Proxy Enabled: 0

    总结

    mac同时连wifi(外网或者vpn)和有线(内网), 如果内网干扰了访问外部ip, 就检查路由表,调整顺序. 如果内网干扰了dns,可以通过scutil –dns查看dns顺序到系统配置里去掉不必要的resolver

    参考资料

    macOS的networksetup命令来管理网络

    在Mac下使用脚本重载proxy自动配置脚本(pac)

    ----------------------------------------------------------

    在Mac下使用脚本重载proxy自动配置脚本(pac)

    Mac下对网络设备使用proxy自动配置脚本可以透明使用代理穿墙(可以配合ssh tunnel和tor)。但是我一直不知道如何用脚本让系统重新载入pac文件(在更新了pac的规则时我们需要重载配置)。昨天一位叫做Dylan的网友留言告诉了我如何做,我在此记录一下。在命令行下面:

    networksetup listallnetworkservices

    然后会会返回一个网络连接服务的列表:
    An asterisk (*) denotes that a network service is disabled.
    Bluetooth DUN
    ADSL
    Ethernet
    FireWire
    AirPort
    Bluetooth PAN

    我一般需要配置pac文件的是Ethernet和AirPort,那么相应的重载命令是:


    sudo networksetup -setautoproxystate 'AirPort' off
    sudo networksetup -setautoproxyurl 'AirPort' 'file://localhost/Users/tin/pac/tin.pac'
    sudo networksetup -setautoproxystate 'AirPort' on
    sudo networksetup -setautoproxystate 'Ethernet' off
    sudo networksetup -setautoproxyurl 'Ethernet' 'file://localhost/Users/tin/pac/tin.pac'
    sudo networksetup -setautoproxystate 'Ethernet' on

    然后pac文件就已经被重载完毕啦。

    顺便共享一下我在bash下的alias:

    alias px='ssh -qTfnNC -D 7777 someuser@server.com'
    alias rpx="sudo networksetup -setautoproxystate 'AirPort' off;sudo networksetup -setautoproxyurl 'AirPort' 'file://localhost/Users/tin/pac/tin .pac';sudo networksetup -setautoproxystate 'AirPort' on;sudo networksetup -setautoproxystate 'Ethernet' off;sudo networksetup -setautoproxyurl 'Ethernet' 'file://localhost/Users/tin/pac/tin.pac';sudo networksetup -setautoproxystate 'Ethernet' on"

    (用privoxy把socks代理转变为http代理,safari浏览器就可以使用代理做dns查询了。)