Arganzheng's Blog

stay hungry, stay foolish

从暴风影音事件反思DNS频率攻击漏洞

蝴蝶效应 令人意想不到的是,这次断网的起因竟然是所谓两个网游私服外挂互掐,一个游戏“私服”的网站打算对它的竞争对手发动攻击,黑客在没法黑掉竞争对手网站的情况下,干脆从域名下手,利用肉鸡攻击对方的免费DNS服务商DNSpod的服务器,大流量的DDoS攻击导致了DNSpod的服务器流量剧增,于是被机房停止了服务,导致DNSpod的DNS服务暂停。而非常不巧的是DNSpod正好是暴风影音的域名解析站,所以数以亿万计的全国的暴风用户集体转向电信的DNS解析服务器发起请求,导致电信的DNS服务器瘫痪,形成了这次席卷中国的大规模网络瘫痪。这次攻击间接导致了6省近一天的网络中断,工信部因此强制介入处理,而暴风影音被迫“史无前例”的召回他们的软件。 这次事件看起来暴风影音也是受...

使用Servlet和JSP模拟最小化的SpringMVC框架

web服务器或应用服务器都是容器,容器只知道与Listener或Servlet打交道,因此所谓的Web MVC框架其实就是预定义了一些Servlet帮我们做了本应该是我们做的事情。 关键:如何用Servlet和JSP实现Web MVC框架 一个Web MVC简单的实现如下:在Servlet中实现web控制逻辑,在它们结束之后,再导向到适当的JSP视图。相应的模型对象将通过Servlet API保存在请求对象(HttpRequest)的属性中,在Servlet控制器和JSP视图之间传递。这也是Web MVC最根本的精髓。 public class MyServlet extends HttpServlet{ //重载doGet()方法 protect...

Groovy元编程——使用invokeMethod和闭包构建DSL和Builder

Since 1.0, Groovy supports the ability to intercept all method and property access via the invokeMethod and get/setProperty hooks. If you only want to intercept failed method/property access take a look at Using methodMissing and propertyMissing. invokeMethod介绍 invokeMethod(String name, Object args) is at the heart of Groovy metaprog...

BDB中的共享区域

2009-5-23 星期六 雨天 1. 数据结构 环境数据结构 DB_ENV{} struct __db_env { int db_lorder; /* Byte order. */ /* Error message callback. */ void (*db_errcall) __P((const char *, char *)); FILE *db_errfile; /* Error message file stream. */ const char *db_errpfx; /* Error message prefix. *...

BDB中的共享区域──MPOOL

2009-5-23 星期六 大雨 1. 数据结构 首先是DB_ENV{}和REGLAYOUT{}对于所有贡献区域都是一样的,在前面已经介绍过了,这里就不赘述了。 我们直接来看MPOOL共享区域数据结构MPOOL{}定义: /* * MPOOL -- * Shared memory pool region. One of these is allocated in shared * memory, and describes the pool. */ struct __mpool { RLAYOUT rlayout; /* General region information. */ SH_TAILQ_...

BDB1.6中的初始化过程──MPOOL初始化

我们前面的讨论都是基于BDB2.7.7版本的,那时候的BDB已经是一个支持事务处理的相当复杂的模块了。现在让我们回过头来看一下BDB1.6版本的初始化过程,那时候的共享区域就只有MPOOL。 首先其入口函数是dbopen(…)函数: DB * dbopen(fname, flags, mode, type, openinfo) const char *fname; int flags, mode; DBTYPE type; const void *openinfo; { #define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) #define USE_OPEN_FLAGS ...

BDB事务共享区域

最后我们来看一下事务共享区域。 首先仍然是每个进程都有的一个数据结构__db_txnmgr{}: /* * The transaction manager encapsulates the transaction system. It contains * references to the log and lock managers as well as the state that keeps * track of the shared memory region. */ struct __db_txnmgr { /* These fields need to be protected for multi-threaded support. */ ...

MPOOL共享内存

2009-5-6 星期三 晴朗 在BDB中所有的共享内存都定义为XXX_REGION{}结构。 比如MPOOL缓冲区,每一个进程有自己的缓存数据结构DB_MPOOL{}: /* * DB_MPOOL -- * Per-process memory pool structure. */ struct __db_mpool { /* These fields need to be protected for multi-threaded support. */ db_mutex_t *mutexp; /* Structure lock. */ /* List of pgin/pgout routin...

BDB日志共享区域

这一次我们对日志共享区域进行分析。 每个进程都有一个DB_LOG{}数据结构: /* * DB_LOG * Per-process log structure. */ struct __db_log { /* These fields need to be protected for multi-threaded support. */ db_mutex_t *mutexp; /* Mutex for thread protection. */ DB_ENTRY *dbentry; /* Recovery file-id mapping. */ #define DB_GROW_SIZE 64 ...

BDB锁共享区域

这一次我们以锁共享区域分析。 /* * The lock table is the per-process cookie returned from a lock_open call. */ struct __db_locktab { DB_ENV *dbenv; /* Environment. */ REGINFO reginfo; /* Region information. */ DB_LOCKREGION *region; /* Address of shared memory region. */ DB_HASHTAB *hashtab; /* ...

×