Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traversal unpin deep nodes list will freeze files api #8301

Open
3 tasks done
bluelovers opened this issue Jul 25, 2021 · 1 comment
Open
3 tasks done

Traversal unpin deep nodes list will freeze files api #8301

bluelovers opened this issue Jul 25, 2021 · 1 comment
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization

Comments

@bluelovers
Copy link

bluelovers commented Jul 25, 2021

Checklist

Installation method

ipfs-update or dist.ipfs.io

Version

{
  ipfs: {

    agentVersion: 'go-ipfs/0.9.1/',
    protocolVersion: 'ipfs/0.1.0',
    version: '0.9.1'
  },
  osystem: 'Windows_NT',
  ram: '26',
  cpu: 'Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz',
  arch: 'x64',
  node: 'v16.5.0',

Config

{
	"API": {
		"HTTPHeaders": {
			"Access-Control-Allow-Credentials": [
				"true"
			],
			"Access-Control-Allow-Headers": [
				"Authorization"
			],
			"Access-Control-Allow-Methods": [
				"HEAD",
				"PUT",
				"GET",
				"POST",
				"OPTIONS"
			],
			"Access-Control-Allow-Origin": [
				"*",
				"http://webui.ipfs.io.ipns.localhost:8080",
				"http://webui.ipfs.io.ipns.localhost:9090",
				"http://localhost:3000",
				"http://127.0.0.1:5001",
				"http://127.0.0.1:5002",
				"https://webui.ipfs.io",
				"https://dev.webui.ipfs.io"
			],
			"Access-Control-Expose-Headers": [
				"Location"
			]
		}
	},
	"Addresses": {
		"API": "/ip4/127.0.0.1/tcp/5001",
		"Announce": [],
		"Gateway": "/ip4/127.0.0.1/tcp/8080",
		"NoAnnounce": [],
		"Swarm": [
			"/ip4/0.0.0.0/tcp/4001",
			"/ip6/::/tcp/4001",
			"/ip4/0.0.0.0/udp/4001/quic",
			"/ip6/::/udp/4001/quic"
		]
	},
	"AutoNAT": {},
	"Bootstrap": [
		"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
		"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt"
	],
	"DNS": {
		"Resolvers": {}
	},
	"Datastore": {
		"BloomFilterSize": 0,
		"GCPeriod": "1h",
		"HashOnRead": false,
		"Spec": {
			"mounts": [
				{
					"child": {
						"path": "blocks",
						"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
						"sync": true,
						"type": "flatfs"
					},
					"mountpoint": "/blocks",
					"prefix": "flatfs.datastore",
					"type": "measure"
				},
				{
					"child": {
						"compression": "none",
						"path": "datastore",
						"type": "levelds"
					},
					"mountpoint": "/",
					"prefix": "leveldb.datastore",
					"type": "measure"
				}
			],
			"type": "mount"
		},
		"StorageGCWatermark": 90,
		"StorageMax": "10GB"
	},
	"Discovery": {
		"MDNS": {
			"Enabled": true,
			"Interval": 10
		}
	},
	"Experimental": {
		"AcceleratedDHTClient": false,
		"FilestoreEnabled": false,
		"GraphsyncEnabled": false,
		"Libp2pStreamMounting": false,
		"P2pHttpProxy": false,
		"ShardingEnabled": false,
		"StrategicProviding": false,
		"UrlstoreEnabled": false
	},
	"Gateway": {
		"APICommands": [],
		"HTTPHeaders": {
			"Access-Control-Allow-Headers": [
				"X-Requested-With",
				"Range",
				"User-Agent"
			],
			"Access-Control-Allow-Methods": [
				"GET"
			],
			"Access-Control-Allow-Origin": [
				"*"
			]
		},
		"NoDNSLink": false,
		"NoFetch": false,
		"PathPrefixes": [],
		"PublicGateways": null,
		"RootRedirect": "",
		"Writable": false
	},
	"Ipns": {
		"RecordLifetime": "",
		"RepublishPeriod": "",
		"ResolveCacheSize": 128
	},
	"Migration": {
		"DownloadSources": [],
		"Keep": ""
	},
	"Mounts": {
		"FuseAllowOther": false,
		"IPFS": "/ipfs",
		"IPNS": "/ipns"
	},
	"Peering": {
		"Peers": null
	},
	"Pinning": {
		"RemoteServices": {}
	},
	"Plugins": {
		"Plugins": null
	},
	"Provider": {
		"Strategy": ""
	},
	"Pubsub": {
		"DisableSigning": false,
		"Router": ""
	},
	"Reprovider": {
		"Interval": "12h",
		"Strategy": "all"
	},
	"Routing": {
		"Type": "dht"
	},
	"Swarm": {
		"AddrFilters": null,
		"ConnMgr": {
			"GracePeriod": "20s",
			"HighWater": 900,
			"LowWater": 600,
			"Type": "basic"
		},
		"DisableBandwidthMetrics": false,
		"DisableNatPortMap": false,
		"EnableAutoRelay": false,
		"EnableRelayHop": false,
		"Transports": {
			"Multiplexers": {},
			"Network": {},
			"Security": {}
		}
	}
}

Description

after doing something like this, then goto http://127.0.0.1:8080/ipns/webui.ipfs.io/#/files

will see file always 404, until restart ipfs

image

export async function deepList(ipfs: IUseIPFSApi, rootStart: string, options?: {
	debug?: boolean,
}, isChild?: true)
{
	options ??= {};
	let map = {} as Record<string, string>

	if (typeof isChild === 'undefined')
	{
		rootStart = rootStart.replace(/\/$/, '')

		if (rootStart[0] !== '/')
		{
			rootStart = '/' + rootStart;
		}

		let stat = await ipfs.files.stat(rootStart + '/', {
			timeout: 2000,
			hash: true,
		});

		map[rootStart + '/'] = stat.cid.toString();

		options.debug && debug(map, rootStart + '/');
	}

	for await (const entry of ipfs.files.ls(rootStart, {
		timeout: 2000,
	}))
	{
		let path = `${rootStart}/${entry.name}`
		let c = '';
		if (entry.type === 'directory')
		{
			c = '/';
		}

		map[path + c] = entry.cid.toString();
		options.debug && debug(map, path + c);

		if (entry.type === 'directory')
		{
			Object.entries(await deepList(ipfs, path, options, true).catch(e => ({} as null)))
				.forEach(([path, cid]) =>
				{
					map[path] = cid;
				})
			;
		}
	}

	return map
}

function debug(map: Record<string, string>, path: string)
{
	console.debug(`deepList`, path, map[path])
}
@bluelovers bluelovers added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Jul 25, 2021
@bluelovers
Copy link
Author

bluelovers commented Jul 28, 2021

this bug happen when some entry can't be resolve

https://discuss.ipfs.io/t/traversal-unpin-deep-nodes-list-will-freeze-files-api/11840

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

1 participant