Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7ddf3836
提交
7ddf3836
authored
10月 20, 2014
作者:
Henry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implemented manual check and update (with signature verification)
上级
5fa3053e
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
79 行增加
和
9 行删除
+79
-9
equinox.yaml
cmd/ipfs/equinox.yaml
+6
-0
update.go
core/commands/update.go
+46
-3
daemon.go
daemon/daemon.go
+2
-0
updates.go
updates/updates.go
+25
-6
没有找到文件。
cmd/ipfs/equinox.yaml
0 → 100644
浏览文件 @
7ddf3836
---
equinox-account
:
CHANGEME
equinox-secret
:
CHANGEME
equinox-app
:
CHANGEME
channel
:
stable
private-key
:
equinox-priv
core/commands/update.go
浏览文件 @
7ddf3836
...
...
@@ -2,21 +2,64 @@ package commands
import
(
"errors"
"fmt"
"io"
"os"
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/updates"
)
// UpdateApply applys an update of the ipfs binary and shuts down the node if successful
func
UpdateApply
(
n
*
core
.
IpfsNode
,
args
[]
string
,
opts
map
[
string
]
interface
{},
out
io
.
Writer
)
error
{
return
errors
.
New
(
"TODOUpdateApply"
)
fmt
.
Fprintln
(
out
,
"Current Version:"
,
updates
.
Version
)
u
,
err
:=
updates
.
CheckForUpdate
()
if
err
!=
nil
{
return
err
}
if
u
==
nil
{
fmt
.
Fprintln
(
out
,
"No update available"
)
return
nil
}
fmt
.
Fprintln
(
out
,
"New Version:"
,
u
.
Version
)
if
err
=
updates
.
AbleToApply
();
err
!=
nil
{
return
fmt
.
Errorf
(
"Can't apply update: %v"
,
err
)
}
if
err
,
errRecover
:=
u
.
Update
();
err
!=
nil
{
err
=
fmt
.
Errorf
(
"Update failed: %v
\n
"
,
err
)
if
errRecover
!=
nil
{
err
=
fmt
.
Errorf
(
"%s
\n
Recovery failed! Cause: %v
\n
You may need to recover manually"
,
err
,
errRecover
)
}
fmt
.
Fprint
(
out
,
err
.
Error
())
return
err
}
fmt
.
Fprintln
(
out
,
"Updated applied! Shutting down."
)
os
.
Exit
(
0
)
return
nil
}
// UpdateCheck checks wether there is an update available
func
UpdateCheck
(
n
*
core
.
IpfsNode
,
args
[]
string
,
opts
map
[
string
]
interface
{},
out
io
.
Writer
)
error
{
return
errors
.
New
(
"TODOUpdateCheck"
)
fmt
.
Fprintln
(
out
,
"Current Version:"
,
updates
.
Version
)
u
,
err
:=
updates
.
CheckForUpdate
()
if
err
!=
nil
{
return
err
}
if
u
==
nil
{
fmt
.
Fprintln
(
out
,
"No update available"
)
return
nil
}
fmt
.
Fprintln
(
out
,
"New Version:"
,
u
.
Version
)
return
nil
}
// UpdateLog lists the version available online
func
UpdateLog
(
n
*
core
.
IpfsNode
,
args
[]
string
,
opts
map
[
string
]
interface
{},
out
io
.
Writer
)
error
{
return
errors
.
New
(
"
TODOUpdateLog
"
)
return
errors
.
New
(
"
Not yet implemented
"
)
}
daemon/daemon.go
浏览文件 @
7ddf3836
...
...
@@ -141,6 +141,8 @@ func (dl *DaemonListener) handleConnection(conn manet.Conn) {
err
=
commands
.
Log
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
case
"unpin"
:
err
=
commands
.
Unpin
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
case
"updateApply"
:
err
=
commands
.
UpdateApply
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
default
:
err
=
fmt
.
Errorf
(
"Invalid Command: '%s'"
,
command
.
Command
)
}
...
...
updates/updates.go
浏览文件 @
7ddf3836
package
updates
import
(
"fmt"
"os"
u
"github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/coreos/go-semver/semver"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/inconshreveable/go-update"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/inconshreveable/go-update/check"
u
"github.com/jbenet/go-ipfs/util"
)
const
(
Version
=
"0.1.0"
// actual current application's version literal
UpdateEndpointURL
=
"https://api.equinox.io/1/Updates"
UpdateAppID
=
"ap_ywkPmAR40q4EfdikN9Jh2hgIHi"
// Version is the current application's version literal
Version
=
"0.1.1"
updateEndpointURL
=
"https://api.equinox.io/1/Updates"
updateAppID
=
"CHANGEME"
updatePubKey
=
`-----BEGIN RSA PUBLIC KEY-----
CHANGEME
-----END RSA PUBLIC KEY-----`
)
var
log
=
u
.
Logger
(
"updates"
)
...
...
@@ -32,12 +40,23 @@ func parseVersion() (*semver.Version, error) {
return
semver
.
NewVersion
(
Version
)
}
// CheckForUpdate checks the equinox.io api if there is an update available
func
CheckForUpdate
()
(
*
check
.
Result
,
error
)
{
param
:=
check
.
Params
{
AppVersion
:
Version
,
AppId
:
U
pdateAppID
,
AppId
:
u
pdateAppID
,
Channel
:
"stable"
,
}
return
param
.
CheckForUpdate
(
UpdateEndpointURL
,
update
.
New
())
up
,
err
:=
update
.
New
()
.
VerifySignatureWithPEM
([]
byte
(
updatePubKey
))
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to parse public key: %v"
,
err
)
}
return
param
.
CheckForUpdate
(
updateEndpointURL
,
up
)
}
// AbleToApply cheks if the running process is able to update itself
func
AbleToApply
()
error
{
return
update
.
New
()
.
CanUpdate
()
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论