Lastest

SS-windows源码分析[2]-如何添加代理服务器

介绍 本系列文章介绍请看:概述 本文旨在搞清楚以下问题: 代理服务器配置管理,添加,删除,修改,获取 加载服务器列表 Call Stack /View/ConfigForm.cs: ConfigForm::ConfigForm -> ConfigForm::LoadCurrentConfiguration -> ConfigForm::LoadServerNameListToUI private void LoadCurrentConfiguration() { _modifiedConfiguration = controller.GetConfigurationCopy(); LoadServerNameListToUI(_modifiedConfiguration); _lastSelectedIndex = _modifiedConfiguration.index; if (_lastSelectedIndex < 0 || _lastSelectedIndex >= ServersListBox.Items.Count) { _lastSelectedIndex = 0; } ServersListBox.SelectedIndex = _lastSelected...

SS源码分析[0]-概述

介绍 shadowsocks-windows是个什么东西我在这里不多说,纯粹研究目的,也没有别的意思。 github项目地址:https://github.com/shadowsocks/shadowsocks-windows 结构 本系列文章将从几方面来解析shadowsocks-windows项目源代码 [0] 概述,本文 [1] 代理服务器配置是如何管理的? [2] 代理服务是如何启动监听和停止监听的? [3] 通信协议是怎么工作的?

SS-windows源码分析[3]-shadowsocks和privoxy的关系以及协作方式

介绍 什么是privoxy 项目地址:https://github.com/unisx/privoxy 文档地址:http://www.privoxy.org/user-manual/quickstart.html 官网上是这么介绍Privoxy的, Privoxy is a non-caching web proxy with advanced filtering capabilities for enhancing privacy, modifying web page data and HTTP headers, controlling access, and removing ads and other obnoxious Internet junk. Privoxy has a flexible configuration and can be customized to suit individual needs and tastes. It has application for both stand-alone systems and multi-user networks. privoxy是一个无缓存的浏览器代理,带有高级的过滤功能,可用于提升隐私安全性,修改网页数据和HTTP头,控制访问,去除广告和其他令人恶心的内容。 读到这里发现shadowsock...

SS-windows源码分析[1]-代理服务器配置是如何管理的

介绍 本系列文章介绍请看:概述 本文旨在搞清楚以下问题: 代理服务器数据结构 数据结构 代理服务器管理界面 代理服务器数据结构 代码位置Model/Server.cs namespace Shadowsocks.Model { [Serializable] public class Server { #region ParseLegacyURL public static readonly Regex UrlFinder = new Regex(@"ss://(?<base64>[A-Za-z0-9+-/=_]+)(?:#(?<tag>\S+))?", RegexOptions.IgnoreCase), DetailsParser = new Regex(@"^((?<method>.+?):(?<password>.*)@(?<hostname>.+?):(?<port>\d+?))$", RegexOptions.IgnoreCase); #endregion ParseLegacyURL private const int DefaultServ...

js创建新元素的几种方式

介绍 为了总结几种新建并插入dom元素到页面某部分的的方式,我们先搭建如下html结构。新建一个html文件,写入如下代码用chrome打开即可。 <!doctype html> <html lang="zh"> <head> <title>测试页面</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <div class="dropdown-menu" id="attributes_list"></div> <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> </body> </html> 有了这个html页面,我们就可以去chrome的debug console测试我们的j...

golang实现类

介绍 类,熟悉java c++ php python等语言中任意一门的人都不会陌生。我假设不行看到这篇文章的人,和我一样有其他高级语言经验。所以这里不废话什么是class。 golang实现 golang并没有提供class关键字来定义类。但是他有struct,并且我们可以给struct添加方法。这样子我们也可以达到实现类功能的目的。 我们来实现一个带有加(add)减(minus)乘(multiple)除(divide)四种操作的Calculator类吧。 首先我们定义一个Calculator接口 package main import "fmt" // 定义计算器的操作 type Calculator interface { add(x int, y int) int minus(x int, y int) int multiply(x int, y int) int divide(x int, y int) float32 } // 定义TestCalculator"类" type TestCalculator struct{ } func (consoleCalculator TestCalculator) add(x int, y int) int { return x + y } func (consoleCalcul...

Golang实现接口编程

介绍 接口是面向对象编程一种重要技术手段。一个接口中包含一组标准操作的签名,任意class只要实现了这个接口的方法,就可以被当做这个接口的子类型来调用。因为这个特性,我们就可以实现功能组件的即插即用,随意替换。 举个cache的例子,这里用java来写: public class Main { public static void main(String[] args){ Cache cache; // 输出:Redis缓存内容 cache = new RedisCache(); System.out.println(cache.get("key")); // 输出:File缓存内容 cache = new FileCache(); System.out.println(cache.get("key")); } } // 缓存接口 interface Cache { Object get(String key); void set(String key, Object value); void delete(String key); } // 基于redis的缓存 class RedisCache implem...

Centos设置系统时区

VPS重置或者更换节点之后,需要调整时区。 这个操作本身不难,可我就是记不住啊。手忙脚乱一通google,不如写在这里好了,方便以后自己找。 列出所有时区 # timedatectl list-timezones 截取北美时区列表如下 America/Toronto America/Tortola America/Vancouver America/Whitehorse America/Winnipeg America/Yakutat America/Yellowknife 选择多伦多,America/Toronto # timedatectl set-timezone America/Toronto 搞定了

Typecho自定义二级菜单样式

背景介绍 先来说说当前的菜单样式吧 系统默认菜单栏实现和样式 // themes/default/sidebar.php 25行 <?php if (!empty($this->options->sidebarBlock) && in_array('ShowCategory', $this->options->sidebarBlock)): ?> <section class="widget"> <h3 class="widget-title"><?php _e('分类'); ?></h3> <?php $this->widget('Widget_Metas_Category_List')->listCategories('wrapClass=widget-list'); ?> </section> <?php endif; ?> 默认模板调用了Widget_Metas_Category_List的listCategories方法来显示导航菜单,那么这个导航菜单的样式就被集成到了listCategories方法中。又是html+php混写。(大家吐槽的不是php, 而是写php的人) 显示效果呢,上个图吧 再来看看Typ...