IPsec/XAuth (Cisco IPsec)

看这个文档了解IPsec/XAuth和Cisco IPsec是一个东西。

阅读全文

WireGuard

从hwdsl2/setup-ipsec-vpn的Readme中的另见里看到了Streisand,看了Streisand中大量的VPN软件,浏览了一下,WireGuard进入视线。从22号开始折腾了两天。

阅读全文

多台机器组成局域网的Vagrantfile

一个局域网,两台Ubuntu 18.04的例子(参考):

阅读全文

MySQL Replication

几天前做了一下MySQL复制的实验。这里记录一下操作日志。

从镜像下载vagrant ubuntu box

1
2
3
vagrant box add \
https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cloud-images/bionic/current/bionic-server-cloudimg-amd64-vagrant.box \
--name ubuntu/bionic64

阅读全文

Iterable转Stream

例子

1
2
3
4
5
6
7
8
9
10
11
List<Map<String, String>> list() {
// Iterable<Album> list = albumRepository.findAll();
return StreamSupport.stream(albumRepository.findAll().spliterator(), false)
.map(album -> {
Map<String, String> map = new HashMap<>();
map.put("uuid", album.getUuid());
map.put("name", album.getName());
return map;
})
.collect(Collectors.toList());
}

阅读全文

JPA分页

参考下面的例子

1
2
3
4
5
// extens CrudRepository 也没报错,可能也行
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
@Query("select u from User u")
Page<User> getUserList(Pageable pageable);
}

阅读全文

coscmd

腾讯云cos提供coscmd支持命令行形式进行cos对象操作。我的需求是希望将文件重命名,但怕影响旧数据,就同时复制并重新命名。
例如:

1
2
# 将 img 桶(chengdu)的 fromFileName.jpg 拷贝到 img-bj 桶(beijing)中,新文件名为toFileName
coscmd -b img-bj-1255000004 -r ap-beijing copy img-1255000004.cos.ap-chengdu.myqcloud.com/fromFileName.jpg toFileName

阅读全文

如何用Java返回没有对应class的JSON结果

使用Map<String, Object>作为返回结果

阅读全文

GatewayPorts

今天为了将本地服务进行内网穿透供外网使用,试了ssh -R,但ss结果看到的只是绑定了127.0.0.1的接口,即使指定了0.0.0.0前缀也不行,查了下,是要在/etc/ssh/sshd_config的配置里把GatewayPorts设置为yes

阅读全文

这样将一个函数变成Promise风格

原函数:

1
2
3
4
5
6
7
8
9
10
11
12
13
cos.postObject({
Bucket: config.Bucket,
Region: config.Region,
Key: Key,
FilePath: filePath,
}, function (err, data) {
if (err) {
wx.showToast({ title: '上传图片错误', icon: 'none' })
console.log(err);
return;
}
wx.showToast({ title: '上传图片成功', icon: 'success' })
});

阅读全文